Skip to content

Instantly share code, notes, and snippets.

@lholden
lholden / functional.hpp
Last active December 18, 2015 01:29
A slightly more "functional" looking API around the c++11 algorithm library. (mostly just mucking around)
#include <iostream>
#include <algorithm>
#include <vector>
#include <cctype>
#include "optional.hpp"
// c++14 optional<T> for c++11.
// https://github.com/akrzemi1/Optional
namespace tr2 = std::experimental;
@lholden
lholden / rc.local
Created April 14, 2012 08:14
Samsung Series 9 Power Savings
#!/bin/sh
echo "noop" > /sys/block/sda/queue/scheduler
echo 5 > /proc/sys/vm/laptop_mode
echo 0 > /proc/sys/kernel/nmi_watchdog
echo 1 > /sys/devices/system/cpu/sched_mc_power_savings
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo ondemand > $i; done
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done
for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo min_power > $i; done
@lholden
lholden / gist:2382480
Created April 14, 2012 06:32
Samsung Series 9 ClickPad
Section "InputClass"
Identifier "np900x4b clickpad"
MatchIsTouchpad "on"
Driver "synaptics"
# Enable the clickpad and set click actions
Option "ClickPad" "1"
Option "ClickFinger1" "1"
Option "ClickFinger2" "1"
Option "ClickFinger3" "1"
[2:00 PM] <@lholden> a library for DCI with Ruby : https://github.com/cjbottaro/schizo
[2:01 PM] <@lholden> I like that way better then the #extend pattern
[2:02 PM] <Skif> I'm liking Data Mapper (not DataMapper) as the inverse of DCI: http://solnic.eu/2012/01/10/ruby-datamapper-status.html
[2:05 PM] <Skif> Note that the linked article does refer to DataMapper, but it's the as yet unrelease 2.x branch
[2:05 PM] <@cschneid> lholden: is there a speed comparison?
[2:05 PM] <@cschneid> I do like it
[2:06 PM] <@cschneid> but dynamically creating fascades everywhere could be expensive
[2:06 PM] <@cschneid> or not. No idea.
[2:06 PM] <@lholden> Eh... most of the time the expense of this sort of stuff wouldn't really be an issue for us. Though, I guarantee it has an overhead :)
[2:06 PM] <@cschneid> sure
CL-USER(15): (glop:with-window (win "My title" 800 600)
(loop while (glop:dispatch-events win :blocking nil) do
(glop:swap-buffers win)))
Resize: 800x600
Draw
debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "initial thread" RUNNING {10029C1523}>:
0 is not defined as a value for enum type #<CFFI::FOREIGN-ENUM
GLOP-BRIDGE:NS-EVENT-TYPE>.
@lholden
lholden / gist:1514171
Created December 23, 2011 13:10
PPPoE on Cisco IOS 15.2
! Or whatever your WAN interface is
interface fastethernet 4
no ip address
ip virtual-reassembly in
pppoe enable group global
pppoe-client dial-pool-number 1
exit
interface dialer 1
@lholden
lholden / .ackrc
Created September 21, 2011 15:22
Ack configuration
--type-add=ruby=.haml,.rake,.rsel,.builder
--type-add=html=.html.erb,.html.haml
--type-add=js=.js.erb
--type-add=css=.sass
--type-set=cucumber=.feature
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc
--ignore-dir=coverage
@lholden
lholden / gist:1186487
Created September 1, 2011 15:54
My Bash Prompt
declare -r MAX_PATH_LENGTH=40
declare -r GIT_PS1_SHOWDIRTYSTATE=true
declare -r COLOR_PATH="\[\e[34;1m\]"
declare -r COLOR_EXTRAS="\[\e[35m\]"
declare -r COLOR_USER="\[\e[1;36;40m\]"
declare -r COLOR_ROOT="\[\e[1;31;40m\]"
declare -r COLOR_HOST=""
declare -r COLOR_RESET="\[\e[0m\]"
@lholden
lholden / gist:1142696
Created August 12, 2011 18:52
Reconfigure Jame's Knight Game to have the ability to manage state
(function () {
var save;
var freshBoard;
var oldSetupGame = this.setupGame;
this.setupGame = function() {
oldSetupGame();
save = freshBoard = saveState();
}
@lholden
lholden / gist:128189
Created June 11, 2009 19:59
Simple gui app in scheme
#lang scheme
(require scheme/gui/base)
(require framework)
(application:current-app-name "TestApp")
(preferences:set-default 'TestApp:size-preference '(600 400)
(λ(size) (and (list? size)
(andmap (λ(i) (positive? i)) size))))