Skip to content

Instantly share code, notes, and snippets.

var tree = SyntaxFactory.ParseSyntaxTree(@"
using System;
namespace NS1
{
public class C
{
int InstanceField = 0;
internal void InstanceMethod()
{
Console.WriteLine(InstanceField);
public class EmtpyStatementRemoval : CSharpSyntaxRewriter
{
public override SyntaxNode VisitEmptyStatement(EmptyStatementSyntax node)
{
//Simply remove all Empty Statements
return null;
}
}
public static void Main(string[] args)
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
var tree = CSharpSyntaxTree.ParseText(@"
public class MyClass
{
public void MyMethod()
{
}
}");
@JoshVarty
JoshVarty / keybindings.json
Last active November 23, 2020 18:32
My keybindings for VSCode.
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+k ctrl+o",
"command": "workbench.action.files.openFolder"
},
{
"key": "ctrl+o",
"command": "workbench.action.files.openFile"
},
learner = load_learner('../data/cropped_faces','effnet_test.pkl',
test=ImageList.from_folder('/home/josh/git/kgl_deepfake/data/cropped_faces/valid'))
# Opening an image with fastai
fastai_img = open_image('/home/josh/git/kgl_deepfake/data/cropped_faces/valid/vylzsyazmx.mp4_1_REAL.jpg')
print(fastai_img.shape)
# Opening an image manually
manual_img = PILImage.open('/home/josh/git/kgl_deepfake/data/cropped_faces/valid/vylzsyazmx.mp4_1_REAL.jpg')
manual_img_array = np.array(manual_img, dtype=np.float32) / 255.
var tree = CSharpSyntaxTree.ParseText(@"
class MyClass
{
int myField = 0;
public int MyProperty {get; set;}
public void MyMethod() { }
}");
var Mscorlib = PortableExecutableReference.CreateFromAssembly(typeof(object).Assembly);
var compilation = CSharpCompilation.Create("MyCompilation",
@JoshVarty
JoshVarty / image_loading.py
Created October 27, 2019 23:36
Testing out a few different ways of loading images.
def get_img_pil(path):
img = Image.open(path)
arr = np.asarray(img)
img.close()
del img
return arr
def get_img_cv2(path):
img = cv2.imread(path)
learn.fit_one_cycle(10, max_lr=(1e-2))
learn.fit_one_cycle(10, max_lr=(1e-2))
learn = cnn_learner(data, models.resnet18, pretrained=False, metrics=[f_score])
learn.unfreeze()
learn.fit_one_cycle(10, max_lr=slice(1e-6,1e-2))