Skip to content

Instantly share code, notes, and snippets.

View jtomaszewski's full-sized avatar

Jacek Tomaszewski jtomaszewski

View GitHub Profile
@mythril
mythril / weinred.sh
Last active December 18, 2015 10:39
weinre init.d script
#!/bin/bash
### BEGIN INIT INFO
# Provides: weinre
# Required-Start: $remote_fs $syslog networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: weinre mobile debugger
# Description: Provides remote front-end debugger for mobile user agents
# like Chrome Inspector or FireBug
@ebeigarts
ebeigarts / RAILS_RELATIVE_URL_ROOT.md
Last active February 2, 2023 15:16
RAILS_RELATIVE_URL_ROOT

RAILS_RELATIVE_URL_ROOT

Rails

By default RAILS_RELATIVE_URL_ROOT is used only for asset pipeline.

To namespace your rails routes you need to wrap run MyApp::Application with map in your config.ru:

map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
@jrhames
jrhames / moment-holidays.js
Last active January 19, 2023 03:12
Holidays plugin for Moment.JS
//## Moment.JS Holiday Plugin
//
//Usage:
// Call .holiday() from any moment object. If date is a US Federal Holiday, name of the holiday will be returned.
// Otherwise, return nothing.
//
// Example:
// `moment('12/25/2013').holiday()` will return "Christmas Day"
//
//Holidays:
@roydekleijn
roydekleijn / LocalStorage.java
Created March 2, 2013 22:35
Selenium WebDriver Javascript execution for localStorage
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
public class LocalStorage {
private JavascriptExecutor js;
public LocalStorage(WebDriver webDriver) {
this.js = (JavascriptExecutor) webDriver;
}
@jedahu
jedahu / es5_ng_it.js
Last active December 13, 2015 20:58
Replacement async 'it' for testing AngularJs with Mocha.
function ngIt($injector) {
return function(text, fn) {
it(text, function(done) {
var $rootScope = $injector.get('$rootScope')
, fin
, finished = function(err) {
fin = true;
done(err);
};
fn(finished);
@nicjansma
nicjansma / ie89-console-apply-support.js
Created January 29, 2013 17:42
Adds .apply() and .call() support to IE8/9's console object, which treates .log()/etc as Objects and not Functions. Requires jQuery for $.each().
if (Function.prototype.bind && typeof console == "object" && typeof console.log == "object") {
var logFns = ["log", "info", "warn", "error", "assert", "dir", "clear", "profile", "profileEnd"];
$.each(logFns, function (i, method) {
console[method] = Function.prototype.call.bind(console[method], console);
});
}
@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@slindberg
slindberg / convert_charset
Created September 26, 2012 19:42
Bash script for converting the charset of all tables in a database
#!/bin/bash
# Convert all tables in a specified database to a different charset
#
# NOTE: this will NOT preserve data if it was stored improperly to begin with,
# e.g. UTF8 encoded strings saved as latin1 charset will get munged by this
# script when the table is converted. To preserve data you must export it, change
# the charset, then re-import.
#
# Command taken from:
@robertjwhitney
robertjwhitney / activeadmin_sortable.js.coffee
Created July 3, 2012 03:37
Simple drag/drop reordering of records in an ActiveAdmin view table
# http://stackoverflow.com/a/8936202
#
# ActiveAdmin already includes the necessary jquery in active_admin/base,
# so just add this to javascripts/active_admin.js after //= require active_admin/base
#
#
# Serialize and Sort
#
# model_name - you guessed it, the name of the model we are calling sort on.
# This is the actual variable name, no need to change it.
@maxim
maxim / spec_helper.rb
Created June 9, 2012 18:14
Making after_commit play nice with use_transactional_fixtures.
# This is an example of how to use database_cleaner gem and
# RSpec tags to make `after_commit` hook play nice with
# `use_transactional_fixtures`.
# Simply mark the specs that use after_commit with
# `:uses_after_commit` tag.
# ...
require 'database_cleaner'