Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jamietre's full-sized avatar
👨‍💻
hacking

James Treworgy jamietre

👨‍💻
hacking
View GitHub Profile
@jamietre
jamietre / gist:1285497
Created October 13, 2011 20:54
Example ExpandoObject implementation
public class JsObject : DynamicObject, IDictionary<string, object>, IEnumerable<KeyValuePair<string, object>>
{
public JsObject()
{
Initialize();
}
public JsObject(object missingPropertyValue)
{
Initialize();
@jamietre
jamietre / gist:4666146
Last active December 11, 2015 21:58
Arabic encoding test with CsQuery
[Test, TestMethod]
public void TestArabic()
{
bool done = false;
string content = null;
CQ dom;
CQ.CreateFromUrlAsync("http://www.ahram.org.eg/Stars-Arts/News/194972.aspx")
.Then(response =>
@jamietre
jamietre / gist:5859816
Last active December 18, 2015 23:09
RunBuild command to invoke a build system for Sublime Text 2 (windows), see http://www.bit-101.com/blog/?p=3439
import sublime
import sublime_plugin
class RunBuildCommand(sublime_plugin.WindowCommand):
def run(self, build_system):
self.window.run_command( "set_build_system", {"file": "Packages/User/"+build_system+".sublime-build" } )
self.window.run_command( "build" )
@jamietre
jamietre / gist:958863
Created May 6, 2011 12:27
Credit card validator
namespace CreditCards
{
public class CardValidation
{
public bool VerifyDate = true;
public string CardName;
public string CCNumber;
public string CCCSV;
public string CCName;
public string CCExp;
@jamietre
jamietre / README.md
Last active July 23, 2017 12:42
List of "right eye first" blu ray movies
  • Bait
  • The Chronicles of Narnia: The Voyage of the Dawn Trader
  • The Darkest Hour
  • Dolphin Tale
  • Drive Angry
  • Edge of Tomorrow
  • Ghostbusters (2016)
  • Gulliver's Travels
  • The Hobbit: An Unexpected Journey
  • The Hobbit: The Desolation of Smaug
@jamietre
jamietre / gist:e031894cd689342d8ee47be132b77528
Last active December 27, 2017 15:44
zsh config for windows-like inline text editing in iterm2 console in MacOS X
# add to .zshrc
r-delregion() {
if ((REGION_ACTIVE)) then
zle kill-region
else
zle $1
fi
}
@jamietre
jamietre / Microsoft.Typescript.targets
Created April 29, 2016 18:14
Better msbuild config for Typescript projects in Visual Studio that tries to use npm modules first
<?xml version="1.0" encoding="utf-8"?>
<!--
***********************************************************************************************
Microsoft.TypeScript.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your web deploy projects from the command-line or the IDE.
This file defines the steps in the standard build process for TypeScript files.
/**
* A reporter that suppresses logs for passing tests
*
* There's no direct way to do this at this point other than a custom reporter. Future
* changes may give us an option to do this without a custom reporter:
*
* https://github.com/facebook/jest/issues/4156
*
* ts-jest seems to not have registered TypeScript extension at the point the reporters are
* registered; this must be JavaScript unless we want to precompile it.
@jamietre
jamietre / import.ps
Created April 20, 2021 11:46
Import local issuer certificates to msys2
get-childitem -path cert:\LocalMachine\Root | ForEach-Object {
$hash = $_.GetCertHashString()
$base64certificate = @"
-----BEGIN CERTIFICATE-----
$([Convert]::ToBase64String($_.export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks))
-----END CERTIFICATE-----
"@
[System.IO.File]::AppendAllText("$home\windows.pem", $base64certificate)
}
@jamietre
jamietre / MethodInfoExtensions
Last active January 7, 2023 06:20
GetSignature extension for PropertyInfo and MethodInfo: returns the detailed method/property signature by reflection
public static class MethodInfoExtensions
{
/// <summary>
/// Return the method signature as a string.
/// </summary>
///
/// <param name="property">
/// The property to act on.
/// </param>
///