Skip to content

Instantly share code, notes, and snippets.

View morozgrafix's full-sized avatar

Sergey Morozov morozgrafix

View GitHub Profile
@morozgrafix
morozgrafix / pil-on-mac.md
Last active December 20, 2015 13:19
Steps to Install PIL on Mac OS X 10.8.4
Install JPEG library:
curl -O -L http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar -zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
sudo CC="gcc -arch x86_64" ./configure -enable-shared -enable-static
sudo make
sudo make install
cd ..
@morozgrafix
morozgrafix / fix_open_with
Last active January 2, 2016 12:49
Fix "Open With" duplicate entries in the OS X
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"
@morozgrafix
morozgrafix / wgetclone
Last active August 29, 2015 13:56
Clone the site with wget
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains site.com \
--no-parent \
site.com
@morozgrafix
morozgrafix / CasperJS Test.sublime-build
Created March 18, 2014 18:56
CasperJS Build System for Sublime Text 2
{
"cmd": ["casperjs", "--no-colors", "test", "$file"],
"selector": "source.js"
}
@morozgrafix
morozgrafix / var_dump.py
Last active August 29, 2015 14:02
var_dump in python
def var_dump(obj):
'''return a printable representation of an object for debugging'''
newobj=obj
if '__dict__' in dir(obj):
newobj=obj.__dict__
if ' object at ' in str(obj) and not newobj.has_key('__type__'):
newobj['__type__']=str(obj)
for attr in newobj:
newobj[attr]=var_dump(newobj[attr])
return newobj
@morozgrafix
morozgrafix / command_line_one_liners.md
Last active August 29, 2015 14:14
handy command line one liners
@morozgrafix
morozgrafix / OS X Emoji Characters and Categories.md
Last active August 29, 2015 14:16
OS X Emoji Characters and Categories

Generate JSON file and save to current directory:

plutil -convert json -r -o `sw_vers -productVersion`.json /System/Library/Input\ Methods/CharacterPalette.app/Contents/Resources/Category-Emoji.plist

Generate JSON file and copy to clipboard:

plutil -convert json -r -o - /System/Library/Input\ Methods/CharacterPalette.app/Contents/Resources/Category-Emoji.plist | pbcopy
@morozgrafix
morozgrafix / timing_curl.md
Last active October 25, 2018 03:23
Time CURL requests
@morozgrafix
morozgrafix / slack_slash_command_template.php
Created January 19, 2016 20:24
Basic Slack Slash Command Bot Template in PHP
<?php
// Authorized team tokens that you would need to get when creating a slash command. Same script can serve multiple teams, just keep adding tokens to the array below.
$valid_tokens = array(
"123asdzxcvasdfasdwasdfas", // key 1
"234xdfqadfsdfasdfasfasdf" // key 2
);
if (!in_array($_REQUEST['token'], $valid_tokens)) {
bot_respond(":no_good: *Unauthorized token!* Feel free to grab a copy of this script and host it yourself.");
@morozgrafix
morozgrafix / darksky1.json
Created December 20, 2016 22:36
example of dark sky json response
{
"latitude": 37.752881,
"longitude": -122.456429,
"timezone": "America/Los_Angeles",
"offset": -8,
"currently": {
"time": 1482272606,
"summary": "Partly Cloudy",
"icon": "partly-cloudy-day",
"nearestStormDistance": 2,