Skip to content

Instantly share code, notes, and snippets.

View fredrikhenne's full-sized avatar

Fredrik Henne fredrikhenne

  • Stockholm, Sweden
View GitHub Profile
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{a09ea7ed-e5fe-459c-8ea9-90bf365d2833}-32]
"AppName"="Foxit Reader.exe"
"AppPath"=hex(2):25,50,72,6f,67,72,61,6d,46,69,6c,65,73,28,78,38,36,29,25,5c,\
46,6f,78,69,74,20,53,6f,66,74,77,61,72,65,5c,46,6f,78,69,74,20,52,65,61,64,\
65,72,00
"Policy"=dword:00000003
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{a09ea7ed-e5fe-459c-8ea9-90bf365d2833}]
@fredrikhenne
fredrikhenne / README.md
Created October 7, 2011 01:31 — forked from jimeh/README.md
A simple key/value store model for Rails using the database and memcache

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.

@fredrikhenne
fredrikhenne / modules.rb
Created July 27, 2011 08:21 — forked from jstirk/modules.rb
TIL 20110727
module AA
module BB
module CC
end
end
end
class Foo
include AA::BB
end

Remove trailing whitespace, convert tabs to spaces and file format to unix (remove ugly ^M carriage returns) from files using a single command:

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' FILES

You could get your FILES using find

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' $(find scripts -name '*.sh' -type f)

If in doubt, ask man.

dir = ARGV.last || '.git'
git_cmd = "git --git-dir=#{dir} --no-pager log --no-merges --date-order --format=format:'%at %h %an %s'"
r, w = IO.pipe
spawn({}, git_cmd, :out => w)
def bold(text)
"\033[1m#{text}\033[0m"
end
#!/bin/bash
clear
# Define text colors
txtwhite='\e[0;37m' # White
txtgreen='\e[0;32m' # Green
txtyellow='\e[0;33m' # Yellow
txtred='\e[0;31m' # Red
SOURCE=net
SYNC_URL='ftp://ftp.ds.hj.se/pub/os/linux/archlinux/$repo/os/x86_64'
HARDWARECLOCK=UTC # UTC is the future, USE IT NOW or else....!
TIMEZONE=Europe/Stockholm
TARGET_GROUPS='base'
TARGET_PACKAGES_EXCLUDE=
TARGET_PACKAGES='e2fsprogs'
#https://bbs.archlinux.org/viewtopic.php?id=103192
#https://wiki.archlinux.org/index.php/AIF_Configuration_File#SOURCE¨
#https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide#Pre-Installation
#https://wiki.archlinux.org/index.php/Beginners'_Guide
#https://wiki.archlinux.org/index.php/GNOME#Base
#https://wiki.archlinux.org/index.php/Display_Manager#Loading_the_display_manager
SOURCE=net
SYNC_URL='ftp://ftp.df.lth.se/pub/archlinux/$repo/os/x86_64'
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['REQUEST_PATH'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
class Client
include Mongoid::Document
field :name
field :description
field :version
references_many :contents
end
class Content