Skip to content

Instantly share code, notes, and snippets.

View alexanderadam's full-sized avatar
⌨️
⌨️

Alexander ADAM alexanderadam

⌨️
⌨️
View GitHub Profile
@axiomsofchoice
axiomsofchoice / gchq-xmas-backdoor.js
Last active December 20, 2015 17:22
Backdoor found in GCHQ Christmas Puzzle
/*
Backdoor found in GCHQ Christmas Puzzle
=======================================
SPOILER ALERT - If you're attempting the puzzle and you don't want to find out
any hints do not read ahead!*
Yesterday I completed Part 4 of the GCHQ Christmas Puzzle
[http://www.gchq.gov.uk/press_and_media/news_and_features/Pages/Director%27s-Christmas-puzzle-2015.aspx].
@nimf
nimf / Rakefile.rb
Last active February 12, 2016 16:56 — forked from drogus/Rakefile.rb
I found this in the answer by Jason to this question http://stackoverflow.com/questions/19206764/how-can-i-load-activerecord-database-tasks-on-a-ruby-project-outside-rails. This is a Rakefile for using ActiveRecord without Rails. It loads ActiveRecord's databases.rake file making ActiveRecord rake tasks available for your non-rails app.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
class Seeder
def initialize(seed_file)
@seed_file = seed_file
end
@adamloving
adamloving / useragent.rb
Created April 1, 2013 21:15
Search strings for common user agents to be filtered out of web page view statistics.
# h = {}; Event.all.each { |e| h[e.useragent] = (h[e.useragent] || 0) + 1; }
# h.keys.each { |k| puts "#{h[k]},#{k}"
class UserAgent
# gplus => "Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0"
BOTS = [
{ :name => 'AppEngine', :match => 'AppEngine', :url => 'http://code.google.com/appengine'},
{ :name => 'Embedly', :match => 'Embedly', :url => 'http://support.embed.ly/'},
{ :name => 'news.me', :match => 'news.me', :url => ''},
{ :name => 'Voyager', :match => 'Voyager/1.0', :url => ''},
{ :name => 'bitlybot', :match => 'bitlybot', :url => ''},
@jagdeepsingh
jagdeepsingh / outlook_calendar_service.rb
Last active June 24, 2016 13:45
Ruby service for Microsoft Outlook calendar API
class OutlookCalendarService
APP_ID = your_app_id
APP_SECRET = your_app_secret
LOGIN_API_DOMAIN = 'https://login.microsoftonline.com'
AUTHORIZE_PATH = '/common/oauth2/v2.0/authorize'
TOKEN_PATH = '/common/oauth2/v2.0/token'
CALENDAR_API_DOMAIN = 'https://outlook.office365.com'
VERSION_PATH = '/api/v2.0'
@nightlyworker
nightlyworker / docker.aliases
Created March 25, 2016 00:35
Docker Bash Aliases
#!/bin/bash
# Use these in your .dotfiles to help make Docker more manageable
$(boot2docker shellinit 2> /dev/null)
alias dip='boot2docker ip 2> /dev/null'
alias dkd="docker run -d -P"
alias dki="docker run -t -i -P"
db() { docker build -t="$1" .; }
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` or `git checkout` if a specified file was changed
# Run `chmod +x post-checkout` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
@axelabs
axelabs / em-dc-unblock.rb
Created March 19, 2015 15:34
Unblocking EventMachine's deferred callbacks
#!/usr/bin/ruby
# Example of how to unblock EventMachine's deffered callbacks
# Based on http://stackoverflow.com/a/11778588/632827
# For output example see: http://goo.gl/d6E9E0
require 'eventmachine'
iam = [ 'blocking', 'non-blocking' ]
@Val
Val / crystal_json_vs_yaml_serialization.cr
Created September 12, 2016 15:33
Crystal JSON vs YAML serialization
require "json"
require "yaml"
require "secure_random"
class SerializableKlass
YAML.mapping({
bool: { type: Bool, nilable: true},
float: { type: Float64, nilable: true},
int: { type: Int32, nilable: true},
str: { type: String, nilable: true}
@kellysutton
kellysutton / gist:2050328
Created March 16, 2012 14:35
ActionMailer assets with hash-based asset hosting

In config/production.rb

  config.action_mailer.asset_host = "https://123123.cloudfront.net"

In config/initializers/mail_image_tag.rb

module ActionView
@jkcavin1
jkcavin1 / dev-tld.md
Last active September 19, 2017 09:02 — forked from marek-saji/dev-tld.md
Configure local DNS server to serve #dev #TLD #ubuntu #linux

Configure local wildcard DNS server

  1. Install Dnsmasq: sudo apt-get install dnsmasq
  2. Since Ubuntu's NetworkManager uses dnsmasq, and since that messes things up a little for us, open up /etc/NetworkManager/NetworkManager.conf and comment out (#) the line that reads dns=dnsmasq. Restart NetworkManager afterwards: sudo restart network-manager with Unbutu > = 15.04 this becomes sudo systemctl restart network-manager
  3. Make sure Dnsmasq listens to local DNS queries by editing /etc/dnsmasq.conf, and adding the line listen-address=127.0.0.1.
  4. Create a new file in /etc/dnsmasq.d (eg. /etc/dnsmasq.d/dev), and add the line address=/dev/127.0.0.1 to have dnsmasq resolve requests for *.dev domains. Restart Dnsmasq: sudo /etc/init.d/dnsmasq restart.

Restart Update: https://help.ubuntu.com/community/NetworkManager source: http://brunodbo.be/blog/2013/04/setting-up-wildcard-apache-virtual-host-wildcard-dns