Skip to content

Instantly share code, notes, and snippets.

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

John Wu xxswingxx

🏠
Working from home
View GitHub Profile
@xxswingxx
xxswingxx / Install ghostscript 9.14.md
Last active October 28, 2015 09:33
Build and install ghostscript 9.14 from src

#Install ghostscript 9.14.md

Uninstall prior versions of ghostscript to avoid conflicts

sudo apt-get remove ghostscript

Install dependencies

 sudo apt-get install liblcms2-2 liblcms2-dev liblcms2-utils
@xxswingxx
xxswingxx / Example form.html
Last active August 29, 2015 14:08
Demo form
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript" src="lib/quaderno-stripe.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
@xxswingxx
xxswingxx / get_average_historical.rb
Last active August 29, 2015 14:12
get_average_historical.rb
require 'csv'
require 'httparty'
require 'byebug'
OANDA_URL = 'https://www.oanda.com/rates/api/v1/rates/'
OANDA_KEY = ENV['OANDA_API_KEY']
OUTPUT_FILE = './rates.json'
year = {
month_1: [],
month_2: [],
@xxswingxx
xxswingxx / post-checkout.sh
Last active February 26, 2016 14:56
Reset database after doing a checkout
#! /bin/sh
# Reset the database only if the previous branch and the current one have different schemas
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
if git diff `git rev-parse --abbrev-ref HEAD` @{-1} | grep "ActiveRecord::Schema.define(version: "; then
rake db:reset
else
# Search term parser from https://gist.github.com/1477730
# Modified to allow periods (and other non-letter chars) in unquoted field values
# and field names.
#
# Helper class to help parse out more advanced saerch terms
# from a form query
#
# Note: all hash keys are downcased, so ID:10 == {'id' => 10}
# you can also access all keys with methods e.g.: terms.id = terms['id'] = 10
# this doesn't work with query as thats reserved for the left-over pieces
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://billing.quaderno.io/billing.js"></script>
</head>
<body>
<a href="#" id="billing1"> Customer 1 </a>
<a href="#" id="billing2"> Customer 2 </a>
@xxswingxx
xxswingxx / quaderno-checkout-v2.md
Last active March 1, 2019 09:06
Quaderno Checkout v2 reference (deprecated)
@xxswingxx
xxswingxx / 01-quaderno-js-v2.md
Last active March 1, 2019 09:12
Quaderno.js v2 reference (deprecated)

Quaderno.js v2 Reference (deprecated)

Quaderno.js is a simple javascript library that allows you to process payments, calculate sales taxes (VAT, GST, etc.) on the fly, and send beautiful tax receipts to your customers.

Note: For more help, take a look at our examples.

Including Quaderno.js

Add these script tags to your page to get started with Quaderno.js.
@xxswingxx
xxswingxx / fix-of-redis-error.md
Created April 28, 2019 10:48 — forked from hivokas/fix-of-redis-error.md
Fix of Redis error (Can't save in background: fork: Cannot allocate memory)

Errors from Laravel logs:

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

ERR Error running script (call to f_1af8e79ebe56ad4d7910f2e116e2555983099baf): @user_script:8: @user_script: 8: -MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

Errors from Redis logs (/var/log/redis/redis-server.log):

* 1 changes in 900 seconds. Saving...
@xxswingxx
xxswingxx / monthly_chart.html
Created October 22, 2019 14:03
amchart month column chart with date parsing
<!-- Styles -->
<style>
#chartdiv {
width : 100%;
height : 500px;
}
</style>
<!-- Resources -->