Skip to content

Instantly share code, notes, and snippets.

View Radagaisus's full-sized avatar

Almog Melamed Radagaisus

View GitHub Profile
jQuery.fn.__defineGetter__ 'tap', ->
console.log "Element:", this
return this
reverse = (fn, args...) ->
fn.apply(this, args.slice(0).reverse())
times = (step, times, fn, args...) ->
checks = 0
interval = reverse setInterval, 1500, ->
if fn.apply(this, args) or checks++ >= times
clearInterval(interval)
detect_facebook_like = ->
@Radagaisus
Radagaisus / css.css
Last active August 18, 2021 10:44
Gauges
.cpt-rank-stats .cpt-rank-right-circle {
background: #bebebe;
height: 90px;
width : 45px;
border-radius: 0 90px 90x 0;
margin-left: -4px;
overflow: hidden;
vertical-align: top;
@Radagaisus
Radagaisus / youtube_url.coffee
Created November 29, 2012 17:43
Get a YouTube Video ID from a Url
# Parses a URL of a YouTube video and
# returns the video id.
#
# - url - the url of the video
#
youtube_url_parser = (url) ->
regex = ///^
.* # Zero or more of any character
( # Group 1, either:
@Radagaisus
Radagaisus / names.coffee
Created December 2, 2012 14:45
First Names for Seed File
exports.names = ['JAMES',
'JOHN',
'ROBERT',
'MICHAEL',
'WILLIAM',
'DAVID',
'RICHARD',
'CHARLES',
'JOSEPH',
'THOMAS',
@Radagaisus
Radagaisus / icons.sh
Created December 3, 2012 16:26
✘ and ✓
# From yeoman's source code
# This prints the ✘ in red,
# rest in bold.
sad_print(){
printf '\e[31m%s\e[0m \e[1m%s\e[0m %s\n' "✘" "$1" "$2"
}
# This prints ✓ in green,
# rest in bold.
@Radagaisus
Radagaisus / implicit-return.coffee
Created December 10, 2012 06:04
Implicit for loops return values
sum = ->
sum = 0
for i in [1..5]
sum += i
k2v = (h) -> (do (k,v) -> (n) -> not (n % v) && k || '') for k,v of fizz: 3, buzz: 5
console.log ((fn(i) for fn in k2v()).join('') || i for i in [1..100]).join "\n"
@Radagaisus
Radagaisus / .bash_profile
Last active August 18, 2021 10:41
Bash prompt
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
GRAY="\[\033[1;30m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"
@Radagaisus
Radagaisus / servers.sh
Created May 21, 2013 23:21
Starts a PHP or a Python server on a directory
# Stolen from a famous dotfile
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}