Skip to content

Instantly share code, notes, and snippets.

View haldun's full-sized avatar
🏝️
v

Haldun Bayhantopcu haldun

🏝️
v
  • Berlin, Germany
View GitHub Profile
@haldun
haldun / gist:1392267
Created November 24, 2011 20:59
Why do humans procrastinate, and how can it be beat?

Kahneman and Tversky, the guys who first really began to probe human cognitive errors, found in their research that there was a systematic human tendency to either under or overestimate the expected value of a reward that varied as a function of time. I'll give you an example. Do you want a dollar today, or 10 dollars in a year? Most people will say a dollar today. How about a dollar today, or 10 dollars in a week? I would take 10 dollars in a week. But does this make sense? I mean, in the first case, I make 9 dollars fewer. Yet, in the second example, I suddenly flip my preference. It turns out that human motivation is heavily influenced by expectations of how imminent the reward is perceived to be. People overestimate the value of the reward if the reward is imminent, and increasingly discount the value of the reward, the further away it is in time. In other words, your perceived utility of an outcome increases with temporal proximity.

So playing skyrim now is more valuable than an A on your paper until te

@haldun
haldun / infixeval.cpp
Created December 1, 2011 15:21
infix evaluator in c++
/*
* Infix evaluator in C++.
* Haldun Bayhantopcu <hb@haldun.me> 10976008
*
* Usage: echo <expr> | ./infixeval
* Example: echo "((8+9)*(4-6)^4)" | ./infixeval
* Output: 272
*/
#include <cmath>
#include <iostream>
@haldun
haldun / quiet_assets.rb
Created December 9, 2011 16:38
rails remove assets logs
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def before_dispatch_with_quiet_assets(env)
before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
end
alias_method_chain :before_dispatch, :quiet_assets
end
@haldun
haldun / gist:1473877
Created December 13, 2011 21:03
textmate line height
defaults write com.macromates.TextMate OakLineHeightDelta 2
@haldun
haldun / split.coffee
Created December 16, 2011 19:31
split text into words
text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
split_text = (text, max_line_size=30) ->
sum = (arr) ->
total = 0
for el in arr
total += el
total
words = text.split(' ')
@haldun
haldun / split.js
Created December 16, 2011 19:32
split text into words
var split_text;
split_text = function(text, max_line_size) {
var current_line, current_line_length, lines, sum, w, word, words, _i, _len;
if (max_line_size == null) {
max_line_size = 30;
}
sum = function(arr) {
var el, total, _i, _len;
total = 0;
for (_i = 0, _len = arr.length; _i < _len; _i++) {
@haldun
haldun / split_pdf.py
Created December 28, 2011 21:33
split pdf into images
import optparse
import os
import sys
import pgmagick
def main():
parser = optparse.OptionParser()
parser.add_option('-i', action='store', dest='input')
parser.add_option('-o', action='store', dest='output')
@haldun
haldun / split_pdf.rb
Created December 28, 2011 21:34
split pdf into images
require 'RMagick'
input = 'presentation.pdf'
image_list = Magick::ImageList.new
image_list.read(input)
image_list.write('jpeg:/tmp/test_%d.jpg')
@haldun
haldun / bingo.rb
Created December 28, 2011 21:35
bingo card generator
require 'prawn'
PrawnSplitWord = Class.new(StandardError)
module Prawn
module Core
module Text
module Formatted #:nodoc:
class LineWrap #:nodoc:
def wrap_by_char(segment)
raise PrawnSplitWord
@haldun
haldun / gist:1542480
Created December 31, 2011 02:03
os x lion how to make the lid open when clamshell mode is on
Here's the command to make your laptop behave like it did Pre-Lion (courtesy of my friend):
sudo nvram boot-args="iog=0x0"
Works perfectly for me. If it screws up your system, just zap the PRAM next boot (cmd-opt-p-r) and you'll be back to the default Lion state. Or if you can still get into terminal, this command will get you back to Lion's default state as well:
sudo nvram -d boot-args
Enjoy!