Skip to content

Instantly share code, notes, and snippets.

@SafeAF
SafeAF / passive-ip-geo-location.js
Created July 2, 2016 06:15
js passive geo locator ui in
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body { margin: 1em; }
#map { height: 500px; }
#intro { font-size: 14px; font-family: arial; max-width: 500px; margin: 1em auto 1em auto; text-align: justify; }
</style>
@SafeAF
SafeAF / api_controller.rb
Created August 20, 2016 23:16 — forked from ahawkins/api_controller.rb
Basic API style controller for Rails
# A Basic API Controller for Rails
# Handles authentication via Headers, params, and HTTP Auth
# Automatically makes all requests JSON format
#
# Written for production code
# Made public for: http://broadcastingadam.com/2012/03/state_of_rails_apis
#
# Enjoy!
class ApiController < ApplicationController
@SafeAF
SafeAF / deploy.rb
Created August 20, 2016 23:22 — forked from ahawkins/deploy.rb
Deploy script for Heroku apps
#!/usr/bin/env ruby
# This is a basic deploy script for Heroku apps.
# It provides a structure you can use to expand on
# and add your own prereqs and deploy tasks.
#
# It basically ensures that:
# 1. There are no uncommited files
# 2. You can ssh to github
# 3. You can connect to heroku
@SafeAF
SafeAF / when-proc.rb
Created August 26, 2016 22:52 — forked from mrb/when-proc.rb
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def am_i_awesome?
@SafeAF
SafeAF / switch.rb
Created August 31, 2016 01:23 — forked from jbr/switch.rb
ruby 1.9.2 case-like switch
# In response to:
# http://mlomnicki.com/ruby/tricks-and-quirks/2011/02/10/ruby-tricks2.html
# Ruby 1.9.2 has some neat stuff that lets us make a readable
# alternative case statement that calls each method in turn.
# 1.9.2 features used:
# * hashes are ordered in 1.9.2
# * cool JSON-style hash syntax
# * concise lambda syntax
@SafeAF
SafeAF / .Dockerfile
Last active October 10, 2016 23:48
Here be dotfiles for a variety of applications and gem libraries etc. Procfiles, Rakefiles, Gemfiles etc
FROM ruby:2.3
ENV LC_ALL C.UTF-8
RUN apt-get update -y \
&& apt-get install -y python-pip \
&& pip install pygments
RUN mkdir -p /app/vendor
WORKDIR /app
@SafeAF
SafeAF / notify-send-replacement.sh
Created September 15, 2016 04:03
Notify-send replacement using gdbus
#!/usr/bin/env bash
# notify-send.sh - drop-in replacement for notify-send with more features
# Copyright (C) 2015 Vyacheslav Levit <dev@vlevit.org>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@SafeAF
SafeAF / Rakefile
Created February 18, 2017 22:23 — forked from robhurring/Rakefile
Delayed Job with Sinatra -- without sinatra specific gems, etc.
task :environment do
require './dj-sinatra'
end
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end
@SafeAF
SafeAF / .gitconfig
Created February 21, 2017 21:59 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com