Skip to content

Instantly share code, notes, and snippets.

View dsignr's full-sized avatar

Neya dsignr

View GitHub Profile
@dsignr
dsignr / Bind rails server to public IP in cloud server.rb
Created April 18, 2016 05:38
How to bind rails default server to the public ip address of your AWS/GCE machine.
sudo rails server -b 0.0.0.0 -p 80
@dsignr
dsignr / README.markdown
Created May 16, 2016 08:54 — forked from floehopper/README.markdown
Generate, send, receive, and parse a multipart/related HTTP POST request in Ruby

Setup Apache to listen on a port and log incoming HTTP requests including body

terminal 1

$ cat /etc/apache2/sites-enabled/mms-test 
Listen 50690
LogLevel debug
DumpIOInput On
# DumpIOOutput On

$ sudo tail -f /var/log/apache2/error.log | grep "mod_dumpio.c(74)" | sed "s/.*HEAP.: //"

@dsignr
dsignr / debug_httparty_request.rb
Created May 17, 2016 22:43 — forked from natritmeyer/debug_httparty_request.rb
How to debug HTTParty requests
class MyResource
include HTTParty
debug_output $stdout # <= will spit out all request details to the console
#...
end
@dsignr
dsignr / api_send_json_response.rb
Created May 18, 2016 04:58
How to send multipart and json requests to Google Drive API using Ruby's HTTParty
class DriveAPI
include HTTParty
base_uri 'https://www.googleapis.com'
#for debugging
debug_output $stdout
end
def create_file(file_name, parent_id)
check_token!
access_token = current_user.access_token
@dsignr
dsignr / haml_partials.haml
Created June 10, 2016 15:27 — forked from janogarcia/haml_partials.haml
HAML Partials wihout Rails (useful for LiveReload)
/ A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails
/ Useful when using tools like LiveReload http://livereload.com/
/ but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials)
/ It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973
/ Check out the Jade version https://gist.github.com/2593727
%html
%body
%header
= Haml::Engine.new(File.read('/path/to/your/partial.haml')).render
@dsignr
dsignr / How to install packages in google datalab.py
Created July 8, 2016 02:00
A short snippet to help you install packages on a google datalab install
# How to install packages:
# %%bash
# pip install <package>
# Deploying NodeJS App on Google Cloud Platform
`authored Jul 3 2015 by kengz`
## Installation
- Account with Google Cloud Platform.
- Install [Google Cloud Platform SDK](https://cloud.google.com/sdk/) to use `cloud` in the terminal.
- Install [Docker](https://cloud.google.com/tutorials/install-docker) for the VM container.
- Locally, login for the first time: `gcloud auth login`
@dsignr
dsignr / Managing Oauth tokens.md
Created August 4, 2016 07:06
R reference for .httr-auth
@dsignr
dsignr / datauri-generator.js
Created August 11, 2016 03:48 — forked from psema4/datauri-generator.js
Generate Data URI's on the fly
// SOURCE: http://davidwalsh.name/convert-image-data-uri-javascript
function getDataUri(url, callback) {
var image = new Image();
image.onload = function () {
var canvas = document.createElement('canvas');
canvas.width = this.naturalWidth; // or 'width' if you want a special/scaled size
canvas.height = this.naturalHeight; // or 'height' if you want a special/scaled size
@dsignr
dsignr / gist:78617a6b0a7a096345a0832f4ba4b5ce
Created August 13, 2016 05:36 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: