Skip to content

Instantly share code, notes, and snippets.

View DouweM's full-sized avatar

Douwe Maan DouweM

View GitHub Profile
@DouweM
DouweM / C# File.sublime-build
Created March 21, 2014 14:00
Sublime C# build file
{
"cmd": ["mcs", "$file", "-r:System.Windows.Forms.dll", "-r:System.Drawing.dll"],
"file_regex": "^(.*?)\\(([0-9]+),([0-9]+)\\): (.*)$",
"selector": "source.csharp"
}
@DouweM
DouweM / 21r.rb
Created April 12, 2014 23:56 — forked from Osagiede/21r.rb
# define global variables here
# define methods here
# for human
user_cards = 0
card_one = rand(1..11)
card_two = rand(1..11)
# for computer
cpu_cards = rand(1..11)
@DouweM
DouweM / gist:1848219
Created February 16, 2012 22:07
Mac AutoTyper
display dialog "Enter text to auto type:" buttons {"Cancel", "OK"} default button 2 default answer ""
set theResult to the result
if the button returned of theResult is "Cancel" then
return
end if
set theText to the text returned of theResult as text
if theText is "" then

I want to display these 4 player wrapper divs as in a grid. I.e.

---------- ----------
|player 1| |player 2|
---------- ----------
---------- ----------
|player 3| |player 4|

@DouweM
DouweM / gist:3966970
Created October 28, 2012 00:09
Proposed Mongoid::Relations::Proxy#eager_load_ids rewrite
def eager_load_ids(metadata, ids)
klass, foreign_key = metadata.klass, metadata.foreign_key
eager_loaded = klass.any_in(foreign_key => ids).entries
ids.each do |id|
IdentityMap.clear_many(klass, { foreign_key => id })
end
eager_loaded.each do |doc|
base_id = doc.__send__(foreign_key)
@DouweM
DouweM / output
Created November 8, 2012 12:35
#{rel}_ids= with Mongoid HABTM
% ./test.rb
a.b_ids = [b.id]
a.b_ids: ["509ba6a40b32cb7486000001"]
a.bs: []
b.a_ids: []
b.as: []
a.bs = [b]
a.b_ids: ["509ba6a40b32cb7486000001"]
a.bs: [#<B _id: 509ba6a40b32cb7486000001, _type: nil, a_ids: ["509ba6a40b32cb7486000002"]>]
@DouweM
DouweM / gist:1811188
Created February 12, 2012 22:25
Overall Gauge
<iframe id="overall_gauge_frame" src="about:blank" style="display: none;"></iframe>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
frame = document.getElementById('overall_gauge_frame')
doc = frame.contentDocument || frame.contentWindow.document
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",
datetime = DateTime.parse('2013-07-14T09:00')
tz = datetime.in_time_zone # => Sun, 14 Jul 2013 09:00:00 UTC +00:00
tz.instance_variable_set(:@time_zone, ::Time.find_zone!("CET"))
tz.instance_variable_set(:@period, tz.send(:get_period_and_ensure_valid_local_time))
tz # => Sun, 14 Jul 2013 09:00:00 CEST +02:00
# :-)
@DouweM
DouweM / request
Last active December 20, 2015 20:09 — forked from abhishek0/request
curl http://localhost:3000/users -d '{"user": { "first_name": "Abhishek", "login_info_attributes": { "password": "p"}}}'