Skip to content

Instantly share code, notes, and snippets.

@selman
selman / awesomium-partial.diff
Created January 22, 2013 19:01
"a/dlls/secur32/schannel_gnutls.c" patch removed. it's avaliable at latest git version.
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index 63107e1..5a47a84 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -179,12 +179,19 @@ end:
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
PCCERT_CONTEXT pCertContext)
{
+ PWINECRYPT_CERTSTORE hcs;
TRACE("(%p)\n", pCertContext);
require 'benchmark'
Benchmark.bmbm(10) do |x|
x.report("noregexp") {
"content-management-systems".split("-").map(&:capitalize).join(" ").
split(" ").map(&:downcase).join("-")
}
x.report("rgexp") {
"content-management-systems".
@selman
selman / custom.el
Created March 8, 2012 23:04
chrome/chromium edit-server customization
(when (and (require 'edit-server nil t) (daemonp))
(edit-server-start))
(setq edit-server-url-major-mode-alist
'(("github\\|\\(posts\\|questions/\\([0-9]+\\)$\\)" . markdown-mode)))
@selman
selman / pinger output
Created February 29, 2012 20:00
network pinging over child processes
time ruby pinger.rb
192.168.1.4
192.168.1.59
192.168.1.90
192.168.1.100
192.168.1.101
192.168.1.102
192.168.1.103
192.168.1.105
192.168.1.107
require "forwardable"
class TheClass
extend Forwardable
attr_reader :items
def_delegators :@items, :<<, :push
def initialize; @items = [] end
end
# http://en.wikipedia.org/wiki/Reverse_Polish_notation
# {method => arity} lookup hash of Float intance methods
METHOD_ARITY = Float.instance_methods(false).inject({}) {|ma, (m, _)|
ma[m] = 0.0.method(m).arity; ma}
def rpn str
str.split(/\s+/).inject([]) do |s, t|
m = t.to_sym
s << case METHOD_ARITY[m]
require 'set'
DIGITS = ('0'..'9').to_a
def solve alphametics
firsts, rests = Set.new, Set.new
alphametics.scan(/\w+/) do |w|
firsts << w[0]
rests += w[1..-1].chars
-- http://en.wikipedia.org/wiki/Combination#Example_of_counting_combinations
module Main where
import Data.Ratio ((%), numerator)
combinationSize :: (Integral a) => a -> a -> a
combinationSize n k = numerator $ cSize n k
where cSize _ 0 = 1
cSize n' k' = (n' - (k' - 1)) % k' * cSize n' (k' - 1)
@selman
selman / day_years.rb
Created August 9, 2011 11:56
girilen araliktaki yillarin ilk gunleri hangi gun?
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# günlerin türkçe karşılığı için array'imiz
DAYS = %w(pazar pazartesi salı çarşamba perşembe cuma cumartesi).freeze
# günü key, yılları value olarak hash'a kaydediyoruz
day_years = (1900..2011).inject({}) do |dy, year|
(dy[Time.utc(year).wday] ||= []) << year
dy
@selman
selman / ales.rb
Created June 26, 2011 19:18
tuxweet hazal
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
class Integer
# sayi basamaklarini array olarak dondurur
def digits
self.to_s.split(//).map!(&:to_i)
end
end