Skip to content

Instantly share code, notes, and snippets.

@sharifulin
sharifulin / gist:261811
Created December 22, 2009 15:56
The Mojolicious example of routes (simple CRUD model)
#!/usr/bin/perl
use common::sense;
use lib '../lib';
$ENV{MOJO_APP} ||= 'App';
use Mojolicious::Commands; Mojolicious::Commands->start;
package App;
use common::sense;
@am0c
am0c / gist:960214
Created May 7, 2011 04:51
perlbrew on eshell
;; eshell init script which let
;; perlbrew to be enabled in emacs eshell environment
;; it is translated from $HOME/perl5/perlbrew/etc/bashrc
;; to elisp script
;;
;; am0c <am0c@perl.kr> http://twitter.com/am0c
;;
(require 'cl)
(defmacro get-home-path () '(getenv "HOME"))
@sjl
sjl / gist:2013603
Created March 10, 2012 22:20
Lobos DB definition for SQLite3
(def db
{:classname "org.sqlite.JDBC"
:subprotocol "sqlite"
:subname "./db.sqlite3"})
@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@miku
miku / csvprocessor.py
Last active July 22, 2019 15:02
CSV processor examples for luigi. Can serialize *args to CSV. Can deserialize CSV rows into namedtuples if requested. -- "works on my machine".
from luigi.format import Format
import csvkit
class CSVOutputProcessor(object):
"""
A simple CSV output processor to be hooked into Format's
`pipe_writer`.
If `cols` are given, the names are used as CSV header, otherwise no
explicit header is written.
@dustinmm80
dustinmm80 / multivm_vagrant_dry.md
Created September 15, 2013 04:48
An example of how to write Vagrantfiles following the DRY principle.
=begin
Example box JSON schema
{
    :name => :name_of_vagrant_box, #REQUIRED
    :ip => '10.0.0.11', #REQUIRED
    :synced_folders => [
        { '.' => '/home/vagrant/myapp' }
    ],
    :commands => [
@higarmi
higarmi / Flatten JSON or a nested dictionary
Created September 26, 2013 01:49
This python recursive function flattens a JSON file or a dictionary with nested lists and/or dictionaries. The output is a flattened dictionary that use dot-chained names for keys, based on the dictionary structure. This allows for reconstructing the JSON structure or converting it to other formats without loosing any structural information.
"""
example: The following JSON document:
{"maps":[{"id1":"blabla","iscategorical1":"0", "perro":[{"dog1": "1", "dog2": "2"}]},{"id2":"blabla","iscategorical2":"0"}],
"masks":{"id":"valore"},
"om_points":"value",
"parameters":{"id":"valore"}}
will have the following output:
{'masks.id': 'valore', 'maps.iscategorical2': '0', 'om_points': 'value', 'maps.iscategorical1': '0',
'maps.id1': 'blabla', 'parameters.id': 'valore', 'maps.perro.dog2': '2', 'maps.perro.dog1': '1', 'maps.id2': 'blabla'}
@jiphex
jiphex / apple-bluetooth-kb-f20.md
Last active July 8, 2024 19:44
Pairing an Apple Bluetooth keyboard with Fedora 20

For some reason, this didn't work with the standard GUI bluetooth tools, so I did the following

  1. Run the command-line bluetoothctl tool
  2. type "agent on"
  3. type "scan on"
  4. press the button on your keyboard, the light should flash if it's not paired with anything else
  5. type "devices" (this shows the list of devices)
  6. type "trust xxxx" where xxxx is the keyboard MAC
  7. type "connect xxxx" where xxxx is the keyboard MAC
  8. type "pair xxxx" where xxxx is the keyboard MAC
@gitaarik
gitaarik / git_submodules.md
Last active July 23, 2024 12:21
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.