据我所知,Git的blob将SHA1哈希作为文件名,以便不复制存储库中的文件.
例如,如果文件A的内容为"abc"并且SHA1散列为"12345",则只要内容不变,则提交/分支可以指向相同的SHA1.
但是,如果将文件A修改为"def"以使SHA哈希"23456",会发生什么?Git是否存储文件A和修改过的文件A(不仅仅是区别,而是整个文件)?
以下"Git社区图书"回答了我的大部分问题.
值得注意的是,这与您可能熟悉的大多数SCM系统有很大不同.Subversion,CVS,Perforce,Mercurial等都使用Delta Storage系统 - 它们存储一个提交和下一个提交之间的差异.Git不会这样做 - 它会在每次提交时存储项目中所有文件在此树结构中的外观.这是使用Git时要理解的一个非常重要的概念.
我想用python和c模式自动打开linum模式(Mx linum-mode).我在.emacs中添加以下代码,但它似乎不起作用.
(defun my-c-mode-common-hook ()
(line-number-mode 1))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(defun my-python-mode-common-hook ()
(line-number-mode 1))
(add-hook 'python-mode-common-hook 'my-python-mode-common-hook)
Run Code Online (Sandbox Code Playgroud)
可能有什么问题?
我安装了F#2.0.0,并使用mono 2.8.
let rec fib n =
match n with
| 1 | 2 -> 1
| n -> fib(n-1) + fib(n-2)
let n = 40
let x = fib(n)
printfn "%d" x
Run Code Online (Sandbox Code Playgroud)
我用fsc.exe编译了这段代码来获取fib.exe.使用mono fib.exe运行它会给我这个错误.
mono fact.exe Could not load file or assembly 'FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Unhandled Exception: System.TypeLoadException: Could not load type '.$Factorial' from assembly 'factorial, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
可能有什么问题?
sudo gacutil -i FSharp.Core.dll
解决了这个问题.
我有一个A类,可以通过两种不同的方式生成.
第一种方法将文件路径作为输入从XML文件解析以获取listA和listB.第二种方法有两个列表.
我可以想到两种方法来实现多个构造函数.你怎么看?通常Python人员使用什么方法来处理这种情况?
class A():
def __init__(self, arg1, arg2 = None):
if isinstance(arg1, str):
...
elif isinstance(arg1, list):
...
a = A("abc")
b = A([1,2,3],[4,5,6])
Run Code Online (Sandbox Code Playgroud)
class A2():
def __init__(self):
pass
def genFromPath(self, path):
...
def genFromList(self, list1, list2):
...
a = A2()
a.genFromPath("abc")
b = A2()
b.genFromList([1,2,3],[4,5,6])
Run Code Online (Sandbox Code Playgroud) 有没有办法使用命令行启动不同的emacs模式?例如,是否可以按如下方式运行emacs?
emacs --org-mode # to start orgmode
emacs --python-mode # to start python mode
Run Code Online (Sandbox Code Playgroud)
之后我可以运行emacs来输入'Mx org-mode',但我想知道我是否可以启动不同的模式.
我有IMessageSender界面.
using System.ComponentModel.Composition;
public interface IMessageSender
{
void Send(string message);
}
Run Code Online (Sandbox Code Playgroud)
我有两个实现此接口的插件.这是plugin.cs.
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using System;
[Export(typeof(IMessageSender))]
public class EmailSender : IMessageSender
{
public void Send(string message)
{
Console.WriteLine(message);
}
}
Run Code Online (Sandbox Code Playgroud)
这是plugin2.cs
[Export(typeof(IMessageSender))]
public class EmailSender : IMessageSender
{
public void Send(string message)
{
Console.WriteLine(message + "!!!!");
}
}
Run Code Online (Sandbox Code Playgroud)
我有这个代码用MEF运行这些插件.
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using System.Collections.Generic;
using System;
public class Program
{
[ImportMany]
public IEnumerable<IMessageSender> MessageSender { get; set; }
public static void Main(string[] …Run Code Online (Sandbox Code Playgroud) 我测试了两种不同的方法来反转python中的列表.
import timeit
value = [i for i in range(100)]
def rev1():
v = []
for i in value:
v.append(i)
v.reverse()
def rev2():
v = []
for i in value:
v.insert(0, i)
print timeit.timeit(rev1)
print timeit.timeit(rev2)
Run Code Online (Sandbox Code Playgroud)
有趣的是,将值插入第一个元素的第二个方法比第一个元素慢得多.
20.4851300716
73.5116429329
Run Code Online (Sandbox Code Playgroud)
为什么是这样?在操作方面,将元件插入头部似乎并不昂贵.
当我的程序试图访问网络驱动器中的DLL时,我收到此错误消息.
Unhandled Exception:
System.IO.FileLoadException: Could not load file or assembly 'file:///Z:\smcho\works\tasks\2011\ni\ng_fpgabackend\myclass.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load maybe dangerous. If this load is not intended to sandbox …Run Code Online (Sandbox Code Playgroud) 当您在WPF的XAML文件中看到Margin属性时,它有四个组件.为什么是这样?前两个组件有意义它们偏离左上方窗口,但当我们有宽度和高度时,第三和第四个组件是什么?
<Grid>
<Button Content="Button" Height="27" HorizontalAlignment="Left" Margin="29,27,0,0" Name="clickButton" VerticalAlignment="Top" Width="86" Click="clickButton_Click" />
<TextBox Height="27" HorizontalAlignment="Left" Margin="29,90,0,0" Name="textBoxOut" VerticalAlignment="Top" Width="276" />
</Grid>
Run Code Online (Sandbox Code Playgroud)