Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / Stop_POODLE.reg
Created February 2, 2015 19:55
If your IE is still vulnerable according to https://www.poodletest.com/ merge this registry setting.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
"Enabled"=dword:00000000
@CTimmerman
CTimmerman / VS2013_edit_during_run.txt
Last active August 29, 2015 14:14
Visual Studio 2013 error: "Changes are not allowed for this module as it was not built for changes while debugging or the target .NET runtime version does not support it."
Given the lack of comment permalinks, link looks, and the broken profile picture update link, i'll mirror my proposed answer at
https://social.msdn.microsoft.com/forums/vstudio/en-US/203a2cbe-bee7-42b2-a97d-1c11b81ae237/my-edit-continue-stopped-working-on-vs-2013?prof=required
To edit a C# program while you're running it in Visual Studio 2013:
1. Go to Project, Properties, Build.
2. Set Platform target: x86
2. Disable "Optimize code"
3. Set Advanced, Debug Info: Full
@CTimmerman
CTimmerman / Node.js_HOWTO.md
Last active September 5, 2021 08:07
Node.js from scratch in Windows
  1. Install Node.js from http://nodejs.org
  2. Open a Command Prompt and run "c:\Program Files\nodejs\npm" install -g learnyounode
  3. Run C:\Users\USERNAME\AppData\Roaming\npm\learnyounode.cmd where USERNAME is your Windows login name.
  4. Instead of writing code in Notepad, I recommend Notepad++ with the NppExec plugin, this F6 script:
NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\Program Files\nodejs\node.exe "$(FULL_CURRENT_PATH)"
@CTimmerman
CTimmerman / filter.js
Last active August 29, 2015 14:15
jQuery table filter trigger for IE10.
$(function(){
$('#filter').on("keyup", filter)
// Too slow? Wait for enter:
//$('#filter').on('change', filter);
// Help IE10 because it doesn't trigger change until field loses focus.
//$('#filter').on('keydown', function(event){if(event.which == 13) $(this).change()})
$('#filter').on("mouseup", function(){setTimeout(filter, 50)}) // Wait for IE10 to clear input.
})
@CTimmerman
CTimmerman / SRXP_key.py
Last active August 29, 2015 14:17
HTTPS POST SRXP API example
import requests # python-requests.org
url = 'https://portal.srxp.com/api/1/access_keys'
post_data = {'email':'xxx', 'password':'xxx'}
response = requests.post(url, json=post_data)
try:
json = response.json()
print("Key: " + json['access_key'])
except:
@CTimmerman
CTimmerman / highlight.js
Created March 23, 2015 14:31
highlight.js
// Highlight 22 popular code types. TODO: Inline for speed and security.
function loadjscssfile(filename, filetype){ // http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
if(filetype=="js"){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if(filetype=="css"){
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
@CTimmerman
CTimmerman / pypyodbc_insert_update.py
Last active August 29, 2015 14:18
pypyodbc insert/update
import pypyodbc # C:\Python34\Scripts>pip install pypyodbc
def printu(s):
try: print(s)
except: print(str(s).encode('ascii', errors='xmlcharrefreplace'))
con = pypyodbc.connect('DRIVER={SQL Server};SERVER=xxx;DATABASE=xxx;UID=xxx;PWD=xxx')
cur = con.cursor()
table = "reports"
@CTimmerman
CTimmerman / SQL_escaper.py
Last active August 29, 2015 14:18
batch replace / escape SQL previewer
def sql_escape(v):
return "'"+str(v).replace("'", "''")+"'"
def fill_sql(sql, values):
"Hacking around hard-to-reproduce pypyodbc bug. Also using tinyint for bools for easy counting."
unique = "%PARAMETER%"
sql = sql.replace("?", unique)
for v in values: sql = sql.replace(unique, "null" if repr(v)=="None" else str(int(v)) if type(v) == bool else repr(v) if type(v) in (int, float) else sql_escape(v), 1)
return sql
@CTimmerman
CTimmerman / namespace_demo.cpp.md
Last active August 29, 2015 14:20
namespace_demo.cpp

Namespaces keep code contained to prevent confusion and pollution of function signatures.

Here's a complete and documented demo of proper namespace usage:

#include <iostream>
#include <cmath>  // Uses ::log, which would be the log() here if it were not in a namespace, see http://stackoverflow.com/questions/11892976/why-is-my-log-in-the-std-namespace

// Silently overrides std::log
//double log(double d) { return 420; }
@CTimmerman
CTimmerman / c_style.py
Last active September 8, 2015 00:07
C-style Python
for i in range(3):
#{
if i == 1:
#{
print('Hello ');
print('World!');
#}
#}