Skip to content

Instantly share code, notes, and snippets.

//Mock API data
let apiData = {
"coord": {
"lon": 115.8333,
"lat": -31.9333
},
"weather": [{
"id": 802,
"main": "Clouds",
"description": "scattered clouds",
void GiganticHackToFixStupidMonoHttpListenerBug(HttpListenerRequest request) {
if (NHyperWeb.RunningUnderMono) {
//On some versions of mono url gets decoded twice, fix that and set the URL back with Reflection
//This is effectively replicating logic in this fix: https://github.com/mono/mono/compare/68c6eed76919...4a8ffc802392
var originalUrl = request.Url;
//Detect incorrect decode
if (originalUrl.PathAndQuery != request.RawUrl) {
try {
var urlBase = new Uri(string.Format("{0}://{1}:{2}", originalUrl.Scheme, originalUrl.Host, originalUrl.Port));
var url = new Uri(urlBase, request.RawUrl, true);
@izevaka
izevaka / golang_tutorial_web_crawler.go
Last active December 21, 2015 05:29
My solution to golang tutorial Web Crawler exercise.
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
@izevaka
izevaka / gist:3653462
Created September 6, 2012 09:10
Crimes against programming humanity
- pkgs2install=\"$METAPKG_NAME=$METAPKG_VERSION `apt-cache showpkg $METAPKG_NAME | awk 'BEGIN { depends=0 } $1 ~ /:$/ { depends=0 } depends == 1 { print } $1 == \"Dependencies:\" { depends=1} ' | grep ^$METAPKG_VERSION | sed -e 's/^[^[:space:]]* - //' -e 's/) /\\n/g' | awk 'BEGIN { ORS=\" \" } $0 == \"\" { next } $3 != \"(null)\" { print $1 \"=\" $3 }'`\"
@izevaka
izevaka / pool-demo.js
Created July 6, 2012 14:54
Connection pooling
//Problem: In node.js, one must pool redis db connections, otherwise they die
//Solution: Use generic-pool
pool = poolModule.Pool({
name: 'redis',
create: function (callback) {
var redisClient = redis.createClient();
callback(null, redisClient);
},
destroy : function (client) {
@izevaka
izevaka / C posts
Created June 20, 2012 22:47
List of My projects and contributions
## C++ blog posts
- http://www.somethingorothersoft.com/2009/12/11/shouldnt-raii-should-be-rdid/
- http://www.somethingorothersoft.com/2010/02/01/double-dispatch-without-rtti/
- http://www.somethingorothersoft.com/2010/02/02/double-dispatch-rtti-vs-pure-vtable/
## C++ StackOverflow posts (sorted by epicness)
- http://stackoverflow.com/questions/2061593/why-do-c-languages-require-parens-around-a-simple-condition-in-an-if-statement
- http://stackoverflow.com/questions/2017623/forward-unbreakable-accessor-class-templates-c/2017783#2017783
info: Creating snapshot 0.0.0-14
info: Updating app runheat
info: Activating snapshot 0.0.0-14 for runheat
info: Stopping app runheat
info: App runheat is now stopped
info: Starting app runheat
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy your application.
error:
@izevaka
izevaka / controller.m
Created May 23, 2012 13:13
Objective-C love letter to Will Hughes
_controllerArray = [NSMutableArray arrayWithObjects:
[[SortedRoomsController alloc] init],
[[SearchableRoomsController alloc] init],
nil
];
//Unit test
/*This particular one is a manual one*/
- (void) controller_should_work
{
/*
* -*- Engage Auth Widget -*-
* Copyright (c) 2011, Janrain, Inc. All rights reserved.
* Version: 2012.14_rc9
* */
if (!Array.prototype.indexOf) Array.prototype.indexOf = function (P) {
for (var R in this) if (this[R] === P) return parseInt(R)
};
if (!Array.prototype.map) Array.prototype.map = function (P, R) {
if (typeof this != "function" || this === null) throw new TypeError;