Skip to content

Instantly share code, notes, and snippets.

View dsignr's full-sized avatar

Neya dsignr

View GitHub Profile
@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 / 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 / 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 / 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 / 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
def before_render(&block)
(@_before_render ||= []) << block
end
def render()
@_before_render.each(&:call)
end
@dsignr
dsignr / DataFrame to GML.ipynb
Last active December 25, 2024 05:25
A python script to extract data from CSV and convert it into Gephi compatible GML.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#http://stackoverflow.com/questions/4150782/using-yaml-with-variables
key : 'This is the foobar var : %{foobar}'
content = file['key']
modified_content = content % { :foobar => foobar }
activate :blog do |blog|
blog.prefix = 'blog'
blog.defaultextension = '.markdown'
blog.sources = 'articles/{category}/{title}'
blog.permalink ='{category}/{title}'
blog.summary_separator = /(READMORE)/
blog.layout = '/blog/bloglayout'
blog.tagtemplate = 'tag.html'
blog.calendartemplate = 'calendar.html'
# Enable pagination
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.