Skip to content

Instantly share code, notes, and snippets.

View Deathspike's full-sized avatar

Deathspike

View GitHub Profile
@Deathspike
Deathspike / gist:5082378
Created March 4, 2013 13:54
Regex html escape direct replace vs function cb replace.
var directReplace = (function () {
var escapeExp = /[&<>"]/, escapeAmpExp = /&/g, escapeLtExp = /</g, escapeGtExp = />/g, escapeQuotExp = /"/g;
return function (text) {
if (text == null) {
return '';
}
var result = text.toString();
if (!escapeExp.test(result)) {
return result;
}
@Deathspike
Deathspike / gist:5366681
Created April 11, 2013 19:57
Fix for Komodo Edit 8 (Iced)CoffeeScript in langinfo_prog.py
class CoffeeScriptLangInfo(_JSLikeLangInfo):
name = "CoffeeScript"
exts = ['.coffee']
common_keywords = set(["true", "false", "null", "this",
"new", "delete", "typeof", "in", "instanceof",
"return", "throw", "break", "continue", "debugger",
"if", "else", "switch", "for", "while", "do", "try", "catch", "finally",
"class", "extends", "super",
"undefined", "then", "unless", "until", "loop", "of", "by", "when",
"and", "or", "is", "isnt", "not", "yes", "no", "on" "off",
@Deathspike
Deathspike / gist:5366683
Created April 11, 2013 19:58
Fix for Komodo Edit 8 (Iced)CoffeeScript in langinfo_prog.py
class CoffeeScriptLangInfo(_JSLikeLangInfo):
name = "CoffeeScript"
exts = ['.coffee']
common_keywords = set(["true", "false", "null", "this",
"new", "delete", "typeof", "in", "instanceof",
"return", "throw", "break", "continue", "debugger",
"if", "else", "switch", "for", "while", "do", "try", "catch", "finally",
"class", "extends", "super",
"undefined", "then", "unless", "until", "loop", "of", "by", "when",
"and", "or", "is", "isnt", "not", "yes", "no", "on" "off",
[
{
"data": "<!DOCTYPE html>",
"type": "doctype"
},
{
"data": "\r\n",
"type": "whitespace"
},
{
@Deathspike
Deathspike / gist:5832139
Created June 21, 2013 15:49
js parsed html tree after consuming lexer tokens
[
{
"data": "<!DOCTYPE html>",
"index": 0,
"type": "doctype",
"indent": 0
},
{
"data": "\r\n",
"index": 15,
@Deathspike
Deathspike / gist:5956468
Created July 9, 2013 10:46
Figure 17 01x13
1
00:02:11,500 --> 00:02:12,980
Okay, got it.
2
00:02:14,570 --> 00:02:16,600
They've found the Mother Maguar.
3
00:02:18,100 --> 00:02:20,050
public byte[] Delta() {
// Make a snapshot of the pixels in RGBA format.
byte[] Snapshot = _Capturer.Snapshot();
// Check if the previous snapshot is invalid.
if (_PreviousSnapshot != null) {
// Initialize a new instance of the MemoryStream class.
using (MemoryStream MemoryStream = new MemoryStream()) {
using (var zipper = new GZipStream(MemoryStream, CompressionLevel.Fastest)) {
// Initialize a new instance of the BinaryWriter class.
using (BinaryWriter BinaryWriter = new BinaryWriter(zipper)) {
@Deathspike
Deathspike / gist:8495642
Created January 18, 2014 20:15
super simple web crawler example (c#) for random people on SO (needs error checking; your job)
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace Crawl {
class Crawlie {
private HashSet<string> _crawled;
private List<string> _matches;
@Deathspike
Deathspike / gist:8496311
Created January 18, 2014 20:56
simple reflection command with interface C#
using System;
using System.Linq;
using System.Reflection;
namespace reflectos {
// interface to implement a command
interface ICommand {
string Name { get; }
void Run();
}
@Deathspike
Deathspike / gist:8496429
Created January 18, 2014 21:04
simple reflection with interface and attribute c#
using System;
using System.Linq;
using System.Reflection;
namespace reflectos {
// interface to implement a command
interface ICommand {
void Run();
}