Skip to content

Instantly share code, notes, and snippets.

View micrypt's full-sized avatar

Seyi Ogunyemi micrypt

View GitHub Profile
@micrypt
micrypt / gist:1207324
Created September 9, 2011 20:59
Fix silly "Networking Disabled" issue (Ubuntu 10.04)
su root
# Don't you hate when you need to root to fix dumb issues?
service network-manager stop
rm /var/lib/NetworkManager/NetworkManager.state
service network-manager start
reboot -h now
@micrypt
micrypt / cartesian.scala
Created October 1, 2011 13:24
Nifty tricks
val l = Seq(Seq(1,2), Seq(3,4), Seq(5,6))
val l2 = l.map(_.map(Seq(_)))
l2.reduceLeft((xs, ys) => for {x <- xs; y <- ys} yield x ++ y)
@micrypt
micrypt / before.scala
Created October 1, 2011 21:08
Squeryl + specs2 examples for a blog post > micrypt.com/2011/07/05/squeryl-specs2-testing-quick-start.html
"allow creation of new entries" >> setupData {
val datum = data.insert(new Datum(0, Some(1),Some(""), Some("ftp.example.org"), Some("username"), Some("password"), Some(new java.util.Date)))
datum.id must_== 1
}
@micrypt
micrypt / Combinations_in_J.j
Created October 7, 2011 23:59
Combinations - In essence: "The problem is one of turning a list of values, say, [A, B, C, D] into a list of pairs with itself, like so [[A,B], [A,C], [A,D], [B, C], [B,D], [C,D]]."
a = 'abcd'
comb=: 4 : 0
k=. i.>:d=.y-x
z=. (d$<i.0 0),<i.1 0
for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
; z
)
(2 comb #a) { a
@micrypt
micrypt / Cake
Created October 29, 2011 14:46
Barcamp London talks
Notes -
Try to get softer butter as it's easier to work with.
Don't overmix. If you do it might cause the cake to not rise properly.
If your cake it golden, then it's done.
Get a torch to if your oven doesn't have a light in it as you don't want to repeatedly open your oven to see how your cake is doing as it let the heat escape.
@micrypt
micrypt / permutationgame
Created November 13, 2011 11:12
Puzzles
Permutation Game (30 Points)
Alice and Bob play the following game:
1) They choose a permutation of the first N numbers to begin with.
2) They play alternately and Alice plays first.
3) In a turn, they can remove any one remaining number from the permutation.
4) The game ends when the remaining numbers form an increasing sequence. The person who played the last turn (after which the sequence becomes increasing) wins the game.
Assuming both play optimally, who wins the game?
Input:
The first line contains the number of test cases T. T test cases follow. Each case contains an integer N on the first line, followed by a permutation of the integers 1..N on the second line.
Output:
@micrypt
micrypt / twitter-user-stylesheet.css
Created December 22, 2011 17:16 — forked from adactio/twitter-user-stylesheet.css
CSS rules to hide "Discover", "Trending Topics", "Who To Follow" and specific people on new new Twitter.
[data-component-term="trends"] *,
[data-component-term="user_recommendations"] *,
[data-component-term="discover_nav"] *,
[data-screen-name="username"] * {
display: none !important;
}
@micrypt
micrypt / dabblet.css
Created January 24, 2012 11:56 — forked from daneden/dabblet.css
Light loader
/**
* Light loader
*/
* {
margin: 0;
padding: 0;
}
html {
@micrypt
micrypt / translation_notes.clj
Created February 7, 2012 01:58
SICP Clojure notes
;; Iterative count
(defn count [sent]
(defn iter [wds result]
(if (empty? wds)
result
(iter (rest wds) (+ 1 result))))
(iter sent 0))
//This wee bit o' CoffeeScript
editor = CodeMirror.fromTextArea(document.getElementById('id_body'),
mode: "markdown"
lineNumbers: false
lineWrapping: true
onCursorActivity: () ->
setLineClass(hlLine, null)
hlLine = editor.setLineClass(editor.getCursor().line, "activeline"))