Skip to content

Instantly share code, notes, and snippets.

View micrypt's full-sized avatar

Seyi Ogunyemi micrypt

View GitHub Profile
set defsearch=yubnub
map <M-w> <Esc>:q<CR>
map <M-t> <Esc>:to<CR>
map <M-]> <Esc>:tn<CR>
map <M-[> <Esc>:tp<CR>
command newpad :to http://typewith.me/ep/pad/newpad
"map gd gT
map gj gt
map gk gT
map gmj <Esc>:tabmove! +1<CR>
/* By dylan (http://www.androidsnippets.org/users/dylan/index.html)
* Considering forking and updating VuDroid (http://code.google.com/p/vudroid/) to add in full screen PDF viewing.
*/
public class FullScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
#!/bin/bash
# Check whether the external monitor is connected
xrandr | grep VGA | grep " connected "
# 0 is returned on success
if [ $? -eq 0 ]; then
gconftool -t string -s /desktop/gnome/background/picture_filename /path/to/wallpaper.png
else
gconftool -t string -s /desktop/gnome/background/picture_filename /path/to/wallpaper_small.png
from django.conf import settings
from django.utils.translation import string_concat, ugettext_lazy
from django.utils.html import strip_tags
from haystack import indexes, site
from cms.models.managers import PageManager
from cms.models.pagemodel import Page
from cms.models.pluginmodel import CMSPlugin
@micrypt
micrypt / OpenGL headers
Created November 27, 2010 13:23
OpenGL headers (freeglut-dev is optional)
sudo apt-get install --reinstall libgl1-mesa-dev mesa-common-dev libgl1-mesa-dri-dev libglu1-mesa-dev freeglut-dev
@micrypt
micrypt / LiftProject.scala
Created March 5, 2011 21:14
Loading Metabroadcast's Maven repository into sbt
import sbt._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
val liftVersion = "2.2"
// uncomment the following if you want to use the snapshot repo
// val scalatoolsSnapshot = ScalaToolsSnapshots
// Adding Metabroadcast's Maven repository
val mavenMetabroadcast = "Metabroadcast Maven Repository" at "http://mvn.metabroadcast.com/all"
#include <string.h>
#include <stdio.h>
#include "handler.h"
void handle_request(int sockfd, const char *request)
{
char *res = "HTTP 200 OK\r\n\r\n";
char file_buf[1024];
char url[1024];
A few more tweaks & I dropped off a wee logo option here: http://dl.dropbox.com/u/6744016/logo_sm.png
body {
font-family: "Amaranth", arial, serif;
text-shadow: 0px 1px -1px white;
}
.button {
clear: both;
background: #39C629;
For what it's worth, my experience learning Scala's type system was:
- plain old (nominal) types: easy, same as Java
- type parameterization: also easy, same as Java, but with square brackets instead of angle brackets. I felt square brackets looked a lot nicer, and probably was therefore easier to read, too.
- function types: functions in Scala have nominal types like anything else, with a type parameter for the result type and one each for the parameter types. But there's also a shorthand syntax. Instead of Function1[String, Int], for example, you can say String => Int. The latter is actually easier to read, but when combined with an assignment such as "val a: String => Int = something I find it can sometimes be non-obvious at first glance how to parse it.
- traits: traits were quite easy for me to understand and use. They are exactly like classes except they can't (currently) take constructor parameters and the meaning of super is different inside them. Mixing in multiple traits is straightforward, as i
@micrypt
micrypt / Python's random.choice
Created April 15, 2011 12:17
Silly hack time: Adding foo.choice to traversables.
import scala.util.Random
class RandomTraversableOnce[A](seq:TraversableOnce[A]){
def choice = seq.toList (new Random nextInt seq.size)
}
implicit def toRandomTraversableOnce[A](seq:TraversableOnce[A]) = new RandomTraversableOnce(seq)