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
  • 04:01 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / transfer-pg-heroku.md
Created January 15, 2013 04:27
Taps is no longer the recommended tool to use when migrating data between postgres instances. Please give heroku-pg-transfer (https://github.com/ddollar/heroku-pg-transfer) a try instead.

First, find the URL to your db on Heroku:

$ heroku config:get DATABASE_URL
postgres://yada:[email protected]:5432/123

Then transfer from the heroku db to your local db:

POST a json {"author":[null]} to server via AJAX request or some other Http Tool.

#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Unsafe Query Generation (CVE-2013-0155)
#
# ## Advisory
#
# https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/t1WFuuQyavI
#
# ## Synopsis
#
# Hack below line in canvg.js in svg.parseXml function before deal with the XML
xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');
# to invoke below code will pupup a download window and allow you to download a canvas as PNG file.
img_PNG = Canvas2Image.saveAsPNG(canvas);
pushToServer: ()->
html2canvas([$(".hidden_container")[0]],{
onrendered: (canvas)=>
strDataURI = canvas.toDataURL()
@temp_container.children().remove()
@temp_container.hide()
$.ajax
url: '/svg/create'
data: {svg: "#{strDataURI}"}
svg = $('svg').parent().html()
canvg('canvas', svg)
canvas = document.getElementById("canvas")
img_PNG = Canvas2Image.saveAsPNG(canvas, true)
$('.chart').html(img_PNG)
svg = $('svg').parent().html()
canvg('canvas', svg)
canvas = document.getElementById("canvas")
img_PNG = "<img src='#{canvas.toDataURL()}' />"
$('.chart').html(img_PNG)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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">