Skip to content

Instantly share code, notes, and snippets.

View MaxPleaner's full-sized avatar

Max Pleaner MaxPleaner

View GitHub Profile
@MaxPleaner
MaxPleaner / 0_reuse_code.js
Created February 10, 2014 00:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@MaxPleaner
MaxPleaner / jquery_google_map_example.js
Last active August 29, 2015 13:57
jquery Google maps example
$(function () {
function initialize() {
// Position map, center @ city center
var page_city_lat = $("#page_city_lat").text();
var page_city_lng = $("#page_city_lng").text();
var mapOptions = {
center: new google.maps.LatLng(page_city_lat, page_city_lng),
zoom: 11
};
@MaxPleaner
MaxPleaner / ruby_socket.rb
Last active August 29, 2015 14:02
broken loop in ruby socket
require 'socket'
server = TCPServer.new(2000)
# An "echo server" read a single line of input from the client, echoes that
# input line back to the client, hangs up, and listens for a new connection.
def echo_prompt(client)
client.puts "Enter some input to echo"
input = client.gets.chomp
@MaxPleaner
MaxPleaner / wonky_coins.rb
Last active August 29, 2015 14:02
wonky coins
def wonky_coins(n)
return 1 if n == 0
# call wonky_coins from inside itself. This is called *recursion*.
return wonky_coins(n / 2) + wonky_coins(n / 3) + wonky_coins(n / 4)
end
@MaxPleaner
MaxPleaner / broken_twitter_client.rb
Last active August 29, 2015 14:02
Twitter client (broken)
require 'json'
require 'simple_oauth'
require 'excon'
require 'nokogiri'
require_relative 'lib/twitter_creds'
def post_tweet(string)
authorization_header = SimpleOAuth::Header.new("post",
"https://api.twitter.com/1.1/statuses/user_timeline.json",
{ :screen_name => "ugly_name",
@MaxPleaner
MaxPleaner / dotenv_syntax.txt
Last active August 29, 2015 14:02
dotenv syntax
require 'dotenv'
Dotenv.load
# Get these from https://apps.twitter.com/ in your applications API Keys tab.
API_KEY=ENV['API_KEY']
API_SECRET=ENV['API_SECRET']
ACCESS_TOKEN=ENV['ACCESS_TOKEN']
ACCESS_TOKEN_SECRET=ENV['ACCESS_TOKEN_SECRET']
http://i.imgur.com/mJcdyct.png
note: "brake" is an alias for "bundle exec rake"
@MaxPleaner
MaxPleaner / keyboard_remapping.txt
Last active August 29, 2015 14:08
xbindkeys - keyboard remapping - custom commands are before "end of config" at bottom
# For the benefit of emacs users: -*- shell-script -*-
###########################
# xbindkeys configuration #
###########################
#
# Version: 1.8.6
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
@MaxPleaner
MaxPleaner / links.txt
Last active August 29, 2015 14:13
links
$.fn.SPA = function( options ) {
// default settings
var settings = $.extend({
toggling_sections: ".toggling",
base_link: "a[href^='#']",
}, options );
// setup initial page layout
$(settings["toggling_sections"]).hide();
// event listeners for links
$(settings["base_link"]).click(function(e){