Skip to content

Instantly share code, notes, and snippets.

View bhagyas's full-sized avatar

Bhagya Nirmaan Silva bhagyas

View GitHub Profile
@bryanchow
bryanchow / utcisoformat.py
Created September 5, 2011 20:34
Convert Django DateTimeField values to ISO format in UTC
# Convert Django DateTimeField values to ISO format in UTC
# Useful for making Django DateTimeField values compatible with the
# jquery.localtime plugin.
#
# https://gist.github.com/1195854
from pytz import timezone, utc
from django.conf import settings
@Overbryd
Overbryd / path-in-mac-osx-10.7.mdown
Created January 24, 2012 09:58
Correcting $PATH in MacOSX 10.7 for homebrew

$PATH in MacOSX 10.7

MacOSX has a truly global path setting that precedes any other setting like ~/.bash_profile. The file /private/etc/paths is a list of pathnames. The order from top to bottom defines the resulting order in the $PATH variable. After loading /private/etc/paths there is a directory /private/etc/paths.d/ with files in the same style. Those are appended to the $PATH variable.

The default content of /private/etc/paths looks like this:

/usr/bin

/bin

Displaying images in the terminal with tput and echo

output

Requires ImageMagick, easily available from your favorite package manager. Tested on Linux and OSX
convert image.png -resize 40 txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/g;s/255/254/g;/mage/d'|awk '{print $1,$2}'|sed -E 's/^0,[0-9]+ /print "echo;tput setaf "\;/;s/^[0-9]+,[0-9]+ /print "tput setaf ";/;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc|sed 's/$/;echo -n "  ";/'|tr '\n' ' '|sed 's/^/tput rev;/;s/; /;/g;s/$/tput sgr0;echo/'|bash
@asciidisco
asciidisco / nha.md
Last active October 20, 2017 20:06
Node homeautomation
package com.ullgren.pontus.camel;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@lelandrichardson
lelandrichardson / ko-convenience.js
Created March 5, 2014 01:11
Knockout.js Custom Utility Bindings
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
href: {
update: function (element, valueAccessor) {
handlers.attr.update(element, function () {
return { href: valueAccessor() };
});
}
},
@higepon
higepon / API.swift
Last active July 31, 2023 16:00
An example of JSON API call in Swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active July 28, 2024 20:01
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@watson
watson / airplay.md
Last active February 5, 2022 03:41
An overview over my AirPlay related modules
@brooksduncan
brooksduncan / scan-apple-notes.scpt
Last active September 14, 2023 15:41
ScanSnap Scan To Apple Notes
(*
Scan To Apple Notes
Copyright (C) Brooks Duncan
v. 1.1
You are welcome to use and modify as you see fit, but I'd appreciate credit to http://www.documentsnap.com.
Learn more at http://www.documentsnap.com/scan-apple-notes
Thank you to Larry Salibra at https://www.larrysalibra.com/evernote-to-apple-notes/.