Skip to content

Instantly share code, notes, and snippets.

View yorzi's full-sized avatar
🏠
Working from home

Andy Wang yorzi

🏠
Working from home
  • Xi'an, China
  • 23:16 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / creating-edgerails-app.sh
Created November 26, 2012 05:48 — forked from peter/creating-edgerails-app.sh
Creating and Deploying an EdgeRails (Rails 4) Application to Heroku
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
@yorzi
yorzi / dump_restore_postgres.md
Last active December 9, 2015 23:29
dump / restore postgresql database.

To dump:

pg_dump dbname > dbname.sql

To restore:

cat dbname.sql | psql dbname

NOTICE:

@yorzi
yorzi / postgis.md
Created December 20, 2012 12:21
enable postgis in postgresql database, use heroku's Postgres.app for instance.

connect to postgres psql -h localhost

create database CREATE DATABASE mydatabase;

switch to your database \connect mydatabase

add postgis extension

@yorzi
yorzi / auto_capture.rb
Created December 22, 2012 10:02
simple sample script to do auto screenshots when browsing some website pages.
#!/usr/bin/env ruby
country_array = %w(
aruba
afghanistan
andorra
angola
anguilla
albania
united-arab-emirates
@yorzi
yorzi / chart.html
Last active December 10, 2015 13:49
<!-- #canvas is to store the generated SVG information -->
<canvas id="canvas" style="display:none;"></canvas>
<div class="title">
Religion Population 2010
<span class="download individual" title="download chart"></span>
<span class="share individual" title="share chart"></span>
</div>
<div class="chart">
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
svg = $('svg').parent().html()
canvg('canvas', svg)
canvas = document.getElementById("canvas")
img_PNG = "<img src='#{canvas.toDataURL()}' />"
$('.chart').html(img_PNG)
svg = $('svg').parent().html()
canvg('canvas', svg)
canvas = document.getElementById("canvas")
img_PNG = Canvas2Image.saveAsPNG(canvas, true)
$('.chart').html(img_PNG)
pushToServer: ()->
html2canvas([$(".hidden_container")[0]],{
onrendered: (canvas)=>
strDataURI = canvas.toDataURL()
@temp_container.children().remove()
@temp_container.hide()
$.ajax
url: '/svg/create'
data: {svg: "#{strDataURI}"}
# to invoke below code will pupup a download window and allow you to download a canvas as PNG file.
img_PNG = Canvas2Image.saveAsPNG(canvas);