Skip to content

Instantly share code, notes, and snippets.

View Sitebase's full-sized avatar
🤘

Wim Mostmans Sitebase

🤘
View GitHub Profile
@Jamedjo
Jamedjo / currency.js
Last active December 18, 2015 02:39
Quick currency detection script I wrote while making http://jamedjo.github.io/Converter/ to test out angularjs
function defaultCurrencyFromLanguage(){
var lang = window.navigator.userLanguage || window.navigator.language;
var symbol = "$";
if(/gb|uk|tr|je|ta|gs|gg|im|sd|sl|vg|cy|eg|fk|gi|lb|sh|ac|ss|sd|sy/i.test(lang)) {
symbol = "£";
}
else if(/me|sk|ea|gf|tf|bl|mf|ie|ee|re|it|mc|si|de|es|at|yt|gp|pm|cy|pt|fr|gr|ic|be|ad|fi|lu|va|mt|sm|mq|nl|ax|cs/i.test(lang)) {
symbol = "€";
}
else if(/cn|jp|fm|sj/i.test(lang)) {
@JorgenEvens
JorgenEvens / deploy-test.sh
Last active December 20, 2015 21:58
Test the build using a custom heroku buildpack on your own machine.
#!/bin/sh
if [ -z $1 ]; then
echo "Usage: $0 project-location"
exit 1
fi
if [ ! -d $1 ]; then
echo "Could not find your project"
exit 2
@raine
raine / heroku-logs-with-bunyan.md
Last active August 3, 2018 19:14
Read heroku log output with bunyan

Read heroku logs output w/ bunyan

The stuff before the JSON in heroku logs output has to be cut off for bunyan to work.

$ heroku logs | sed -l 's/.*app\[web\..*\]\: //' | bunyan

Flag -l makes the output buffered by line.

@basecode
basecode / detect_special_characters.py
Created December 22, 2011 11:15
'no-break space' detection plugin for Sublime Text 2
# encoding: utf-8
import sublime, sublime_plugin
class DetectSpecialCharacters(sublime_plugin.EventListener):
def on_load(self, view):
sublime.status_message("detect_special_characters is active")
def on_modified(self, view):
# find no-break space
special_characters = view.find_all(u"\u00A0")
@coderberry
coderberry / Ruby.sublime-settings
Created October 17, 2011 16:34
Ruby.sublime-settings
{
// The number of spaces a tab is considered equal to
"tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
"font_face": "Droid Sans Mono",
"font_size": 15,
@DonnchaC
DonnchaC / coinbase-oauth-poc.py
Created May 5, 2013 20:00
This is a proof-of-concept script which exploited a bug in Coinbase.com's implementation of OAuth. More information and demo at https://vimeo.com/user18139365/coinbase-oauth-poc. Coinbase are pretty generous and gave a 5 BTC bounty for this bug which give an attacker full control of an account, when a logged in user visits their malicious web pa…
# -*- coding: utf-8 -*-
# Coinbase.com OAuth Authorization PoC
# Donncha O'Cearbhaill - 4/05/13
# @DonnchaC
# donnchacarroll@gmail.com - PGP: 0xAEC10762
import requests
import json
from BeautifulSoup import BeautifulSoup
from flask import Flask, request, render_template
@jonah-williams
jonah-williams / circle.yml
Last active May 29, 2019 14:53
Automating deployments to Heroku from CircleCI
test:
override:
- bundle exec rspec spec
deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
timeout: 300
@samkeen
samkeen / TestingCodeigniter.md
Created August 12, 2011 14:54
Article describing how to test Codeigniter apps

(Integration) Test Infecting Codeigniter

Intro

This is not an article on the theoretical proper way to implement a testing policy and/or infrastructure. This is much more real world than that. This is about finding yourself in a situation were you need to refactor or add features to an existing substantial code base. Before undertaking such an adventure you would like to lay down some tests for regression purposes. The hitch is that the code is in a framework that hasn't put testing support first.

Many PHP frameworks qualify for the statement above but the one we will talk about in this article is Codeigniter. I wont use this article to debate the quality of the Codeigniter code base. It is what it is and finds itself used for a very many (in production) websites. What this article is about is addressing the situation that there are many developers out there that may find themselves working on a product utilizing a framework such as Codeigniter

@wankdanker
wankdanker / broadcast.js
Created November 2, 2011 18:51
simple test cases for broadcast and multicast compatibility between node.js v0.4.x and v0.6.x
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
var testMessage = "[hello world] pid: " + process.pid;
var broadcastAddress = '255.255.255.255';
var broadcastPort = 5555;
socket.setBroadcast(true);
socket.bind(broadcastPort, '0.0.0.0');
@iampeter
iampeter / gist:5af9c9e113e41c954364
Last active April 14, 2020 13:00
Simple proxy with hapi.js to fix your CORS problems

Problem

While building a JavaScript single page app that acts as a front-end to multiple backend servers, even if they are on the same host as the web app - but on different ports, you come across CORS issues.

Solution

Use a simple node.js + hapi.js server to:

  1. Serve your static single page app
  2. Act as proxy to the backend servers