Skip to content

Instantly share code, notes, and snippets.

@punund
punund / angular-inspect
Created January 28, 2015 22:55
How to check Angular service from console
angular.element(document.querySelector('.ng-scope')).injector().get('MyService')
for i in */; do
cd $i
zip $i *
cd ..
done
#
# it suits my purposes, no warranty if is suits yours
# Iļja Ketris
#
include "/usr/share/X11/locale/en_US.UTF-8/Compose"
<Multi_key> <minus> <greater> : "→" U2192 # RIGHT
<Multi_key> <less> <minus> : "←" U2190 # LEFT
<Multi_key> <period> <space> : "…" U2026 # HORIZONTAL ELLIPSIS, многоточие
@punund
punund / 0_reuse_code.js
Created January 21, 2014 10:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@punund
punund / gist:7965186
Created December 14, 2013 21:35
два файла конфигурации nginx
ike@osaka:~$ cat /etc/nginx/sites-available/node-configly
server {
listen 80;
server_name www.config.ly;
location / {
proxy_pass http://unix:/var/run/proxy.sock/node-configly.80:$uri$is_args$args;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
# Delete branches not tracked by remote
git remote prune origin
# Prettier log
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
var bases = require('bases');
var crypto = require('crypto');
// Returns a base-62 (alphanumeric only) string of the given length:
function randomStr(length) {
// We generate a random number in a space at least as big as 62^length,
// and if it's too big, we just retry. This is still statistically O(1)
// since repeated probabilities less than one converge to zero. Hat-tip to
// a Google interview for teaching me this technique! ;)
indexB: ->
x = fs.readFileSync xmlInput
parser.parseString x, (error_xml, res_xml) ->
for product in res_xml?.products?.product[0..0]
r = request
uri: S.Found.uri + '/stock/one'
method: 'POST'
json: product
r.pipe process.stdout
@punund
punund / getImageSize.coffee
Created November 11, 2012 19:57
Retrieves first chunk of data of remote image via HTTP GET to find out its size in pixels. PNG, JPEG
getImageSize = (image, cb) ->
fromHex = (hex) -> parseInt "0x#{hex}", 16
req = http.request image, (res) ->
res.setEncoding 'hex'
res.on 'error', (e) -> cb "getImageSize error (#{image}): " + e, null, image
res.on 'data', (chunk) ->
m = switch res.headers['content-type']
when 'image/jpeg'
chunk.match 'ffc0001108(....)(....)'
when 'image/png'
@punund
punund / splitter.sh
Created November 24, 2011 00:16
splitter in bash
#!/bin/bash
[[ $1 =~ ([[:alnum:]]+)-([[:alnum:]]+) ]] || exit 1
[[ "$2" = suffix ]] &&
echo ${BASH_REMATCH[2]} && exit 0
echo ${BASH_REMATCH[1]} && exit 0