Skip to content

Instantly share code, notes, and snippets.

@clupasq
clupasq / Vs2013DevCmdPrompt.ps1
Created September 16, 2014 15:52
Set Developer Command Prompt (VS 2013) in PowerShell
Function vs2013CommandPromptVariables()
{
pushd 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools'
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
@clupasq
clupasq / wifi_hotspot.bat
Created September 30, 2014 11:53
Win 8 WIFI Hotspot
REM Follow instructions at https://www.youtube.com/watch?v=2pvK-6321ig
REM If it does not work (keeps waiting at obtaining IP address) repeat the first step:
REM - go to "network connections", select the connection you want to share. Go to "properties" and "sharing".
REM - Deselect "Allow other users to connect through this computer's Internet connection". Click "OK".
REM - Go to "properties" and "sharing" again.
REM - select "Allow other users to connect through this computer's Internet connection". Select the network you just created just below that. Click "OK"
REM - Try again to connect. Should work.
netsh wlan set hostednetwork mode=allow ssid=TheW0lf key=<password_here>
netsh wlan start hostednetwork
@clupasq
clupasq / gist:44097e5c2c2baca54903
Created November 4, 2014 20:01
VIM macro to run Ruby
map ,t :w\|!ruby %<cr>
@clupasq
clupasq / so_notifier.js
Last active August 29, 2015 14:10
StackOverflow New Question Sound Notification
(function () {
'use strict';
var model = {
alarmActive: true
};
var controller = {
init: function() {
if (this.alreadyRunning()) {
@clupasq
clupasq / Codio Default Prefs
Last active August 29, 2015 14:11
Exercism guard -d with `LISTEN_GEM_DEBUGGING=2`
[editor]
;Show line numbers.
; Type: boolean
line_numbers = true
;Visible tabs.
; Type: boolean
visible_tabs = false
@clupasq
clupasq / memo.py
Created January 24, 2015 21:49
Python memoisation decorator
# taken from the "Design of Computer Programs" course by Peter Norvig
# https://www.udacity.com/course/cs212
from functools import update_wrapper
def decorator(d):
"Make function d a decorator: d wraps a function fn."
def _d(fn):
return update_wrapper(d(fn), fn)
update_wrapper(_d, d)
@clupasq
clupasq / car_van.js
Created February 13, 2015 12:04
JavaScript Pseudoclassical Subclass example
console.clear();
function Car(name, loc) {
this.name = name;
this.loc = loc;
}
Car.prototype.move = function(){
this.loc++;
console.log(this.name + "'s location is now " + this.loc.toString());
};
@clupasq
clupasq / gist:fd00f20ba537408d1a0b
Created February 20, 2015 22:14
Programming Puzzles and Code Golf character counter for answers
/* stolen from http://stackoverflow.com/a/5515960/390819 */
function lengthInUtf8Bytes(str) {
/* Matches only the 10.. bytes that are non-initial characters in a multi-byte sequence. */
var m = encodeURIComponent(str).match(/%[89ABab]/g);
return str.length + (m ? m.length : 0);
}
var answers = document.querySelectorAll('div.answer');
var codeBoxes = Array.prototype.map.call(answers, function(a){
@clupasq
clupasq / js_test.js
Created June 8, 2015 14:32
JavaScript Simple Asserts
function assertEquals(expected, actual){
if(expected === actual){
console.info('OK');
} else {
console.error('(' + expected + ') !== (' + actual + ') !!!');
}
}
function assertThrows(f){
try{
@clupasq
clupasq / gist:1736646
Created February 4, 2012 09:20
get original URL from short URL (ex: bit.ly)
static string GetOriginalUrl(string shortUrl)
{
var httpRequest = (HttpWebRequest) WebRequest.Create(shortUrl);
httpRequest.Method = "HEAD";
using (var response = httpRequest.GetResponse())
return response.ResponseUri.AbsoluteUri;
}