Skip to content

Instantly share code, notes, and snippets.

@hraban
hraban / gist:3017681
Last active August 15, 2016 12:25
My .emacs (hraban)
(add-to-list 'load-path "~/.emacs.d/plugins")
;; cl-* functions and macros
(require 'cl)
(cl-defmacro if-exists ((var fname) &rest body)
`(let ((,var ,fname))
(when (file-exists-p ,var)
,@body)))
@hraban
hraban / vectorized-arrays.js
Last active November 10, 2016 15:12
Vectorized .all method on arrays to transparently access all members
Object.defineProperty(Array.prototype, 'all', {
get: function () {
return new Proxy(this, {
get: function(target, name, receiver) {
return target.map(x => x[name]);
},
set: function (target, name, value) {
target.forEach(x => x[name] = value);
},
// ... call:, etc.
@bschlenk
bschlenk / ini2json.py
Last active March 3, 2017 13:56 — forked from Natim/ini2json.py
Convert an ini configuration file into a json file. Retains original order of ini file entries and prints json out with four space indentation.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import sys
from collections import OrderedDict
from ConfigParser import (ConfigParser, MissingSectionHeaderError,
ParsingError, DEFAULTSECT)
@kerorotg
kerorotg / gist:1886569
Created February 22, 2012 18:39 — forked from ttilley/gist:1737625
mac sandbox and code signing conveniences
//
// CodeSignConveniences.h
//
// Created by Travis Tilley on 2/4/12.
// Copyright (c) 2012 Travis Tilley. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Security/CodeSigning.h>
@hc2p
hc2p / .travis.yml
Last active November 13, 2020 04:26
This is a prove of concept for leveraging the travis directory caching for speeding up docker builds. It works by configuring the docker deamon to use a folder under current user's (travis) control. That way you have the privileges to use the caching feature of travis ci.
sudo: false
services:
- docker
before_script:
- sudo service docker stop
- if [ "$(ls -A /home/travis/docker)" ]; then echo "/home/travis/docker already set"; else sudo mv /var/lib/docker /home/travis/docker; fi
- sudo bash -c "echo 'DOCKER_OPTS=\"-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -g /home/travis/docker\"' > /etc/default/docker"
- sudo service docker start
@hraban
hraban / README.md
Last active April 13, 2022 17:42 — forked from jamesmacfie/README.md
iTerm 2 - script to change theme depending on Mac OS dark mode
@keithamus
keithamus / Nano Git Commit Syntax highlighting
Created December 10, 2010 13:58
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"
@mikroskeem
mikroskeem / gccemacs_osx.md
Last active July 11, 2023 14:59
gccemacs on OSX

gccemacs on OS X

Read this first: http://akrl.sdf.org/gccemacs.html

Prerequisites

1) GCC with libgccjit enabled

For that you need to compile gcc (duh). I edited Homebrew's gcc formula:

@ANDRON94
ANDRON94 / eval-when-test.lisp
Last active August 13, 2023 20:56
Explanation of how 'eval-when' works in Common Lisp
;;; explanation for LOAD *.lisp
;;; 1. Load ignores :compile-toplevel, :load-toplevel
;;; Result: NIL is returned
;;; explanation for COMPILE
;;; 1. not-compile-time(NCT)
;;; 2. ignore mode, EVAL, remains in current mode
;;; Result: print to output 'foo-compile'
;;; explanation for LOAD *.fasl
@Natim
Natim / ini2json.py
Created January 11, 2013 10:21
Convert an ini configuration file into a json file
# -*- coding: utf-8 -*-
import json
import sys
from ConfigParser import (ConfigParser, MissingSectionHeaderError,
ParsingError, DEFAULTSECT)
class StrictConfigParser(ConfigParser):
def _read(self, fp, fpname):