Skip to content

Instantly share code, notes, and snippets.

View linglung's full-sized avatar

linglung

  • C+ Java
View GitHub Profile
@linglung
linglung / gist:80a0be7728dc825ff5cccb2814efe47a
Created January 9, 2017 09:38 — forked from fabriciocolombo/gist:4279304
Capturing console output with Delphi
//Anonymous procedure approach by Lars Fosdal
type
TArg<T> = reference to procedure(const Arg: T);
procedure TForm1.CaptureConsoleOutput(const ACommand, AParameters: String; CallBack: TArg<PAnsiChar>);
const
CReadBuffer = 2400;
var
saSecurity: TSecurityAttributes;
hRead: THandle;
@linglung
linglung / getYoutubeId.coffee
Created January 16, 2017 01:57 — forked from Zaggen/getYoutubeId.coffee
Youtube id regex matcher
getYoutubeId = (url)->
regExp = ///
^(?:https?:\/\/)? # Optionally checks if the string starts with http:// or https://
(?:www\.)? # Optionally checks if the string has a www. (after the http, https or starts with it)
youtu\.?be(?:\.com)? # Matches the youtube domain, which could be youtube.com or youtu.be
\/(?:v\/|.*u\/\w\/|embed\/|watch\?v=)? # Matches the url paths that could go before the id, like /embed/ or /watch?v=
([^#\&\?]*) # (CAPTURING-GROUP) Matches any id-like string
# Now if the pattern before did not find anything, we try the one below
|^([0-9,a-zA-Z\-]+)$ # (CAPTURING-GROUP) Matches any id-like string, so passing only the id will return it back
// Run from the dev tools console of any Youtube video
// Accurate as of October 28, 2016. Uses quality + video type for naming now,
// prevents video urls being overwritten.
// ES6 version
const videoUrls = ytplayer.config.args.url_encoded_fmt_stream_map
.split(',')
.map(item => item
.split('&')
.reduce((prev, curr) => (curr = curr.split('='),
@linglung
linglung / youtube api video category id list
Created February 14, 2017 01:56 — forked from dgp/youtube api video category id list
youtube api video category id list
2 - Autos & Vehicles
1 - Film & Animation
10 - Music
15 - Pets & Animals
17 - Sports
18 - Short Movies
19 - Travel & Events
20 - Gaming
21 - Videoblogging
22 - People & Blogs
@linglung
linglung / submit.md
Created March 26, 2018 23:59 — forked from tanaikech/submit.md
Binance API for Google Apps Script

Binance API for Google Apps Script

This sample script is for using Binance API by Google Apps Script. This script encryptes "signature" like samples. In this script, "Example 1: As a query string" is used, and it retrieves "All orders (SIGNED)" by "GET".

function main() {
    var key = '#####'; // Please input your key.
    var secret = '#####'; // Please input your secret.
    var api = "/api/v3/allOrders"; // Please input API Endpoint you want.
    var timestamp = Number(new Date().getTime()).toFixed(0);
 var string = "symbol=LTCBTC&amp;timestamp=" + timestamp; // Please input query parameters for the inputterd API.
@linglung
linglung / openOrderMonitor.js
Created March 27, 2018 05:47 — forked from codeninja/openOrderMonitor.js
Node JS Script to check Binance for open orders and notify when they are filled.
//this script will monitor for all pairs and find any open orders for that pair.
// I've done my best to account for throttling and make the script robust.
// save locally, add your api key, and run with "node <script name>" in console.
// You'll get alerted (in console) when an order fills.
// if you'd like to send a donation my way:
// BTC: 1JD595vphvXmWEwpjiUmfw3QzsBtE9jUP7
// LTC: LcaHE2dqrH73xLtoKXwDZEUtDiY42iAvk4
// ETH: 0x110191093ffab1f0d3d6012cc0de15f42257b7f6
// BNB: 0x110191093ffab1f0d3d6012cc0de15f42257b7f6
// [email protected] for questions... I'll do my best to support the script if you find any bugs.

SheetConverter library (formerly "Spreadsheet to HTML")

This is the source repository for the SheetConverter Google Apps Script library.

Libary documentation is available here.

Caveats

This script is incomplete, ignoring some types of formatting. (Feel free to fork and enhance it, if you wish! Broadly applicable enhancements can be merged and the library updated) There are also some known issues:

@linglung
linglung / pullJSON.js
Created April 5, 2018 07:13 — forked from varun-raj/pullJSON.js
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index
// 2. Fixed Issue: when the path and the rule partially matched but not under the same xpath, it will still print that value under that xpath.
/**
@linglung
linglung / gist:395822dafdbd345d63ed904fdac3c7b5
Last active October 16, 2018 19:23 — forked from mhawksey/gist:1442370
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var content = JSON.parse(response.getContentText()); //
var data = content.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}