Skip to content

Instantly share code, notes, and snippets.

View kbk0125's full-sized avatar

Kevin Kononenko kbk0125

View GitHub Profile
@kbk0125
kbk0125 / cbBasic.js
Last active April 7, 2016 03:43
A simple jQuery callback
$('.myButton').click(function(){
$('.secondEl').show();
});
$('.myButton').click(minion(){
$('.secondEl').show();
});
$('button').click(function(){
console.log("One");
$('.firstChild').show(function(){
console.log("Two");
$('.childofChild').show();
});
console.log("Three");
});
$('button').click(minion(){
console.log("One");
$('.firstChild').show(minion(){
console.log("Two");
$('.childofChild').show();
});
console.log("Three");
});
// generic reportOrders that shows your orders to the function
function reportOrders (minionOrders) {
if ( typeof minionOrders === "string"){
console.log(minionOrders);
}
else if ( typeof minionOrders === "object"){
for (var item in minionOrders) {
console.log(item + ": " + minionOrders[item]);
}
}
// generic reportOrders that shows your orders to the function
function reportOrders (minionOrders) {
if ( typeof minionOrders === "string"){
console.log(minionOrders);
}
else if ( typeof minionOrders === "object"){
for (var item in minionOrders) {
console.log(item + ": " + minionOrders[item]);
}
}
var request = require('request');
var app = require('express')();
var results;
function logRes(){
console.log(results);
}
app.get('/storeData', function(req,res){
readResult(logRes)
var request = require('request');
var app = require('express')();
var results;
function logRes(){
console.log(results);
}
app.get('/storeData', minion1(req,res){
readResult(logRes)
// First line of function
blockspring.runParsed("query-google-spreadsheet", {
// Here is where you need to decide what data you are grabbing with the Google query syntax
// I am finding elements that match the variable num, which is from a previous part of the code
// Google syntax makes you request columns with letters as opposed to your column titles.
"query": "SELECT A, C WHERE B ="+num,
// This is the full URL of your sheet. Just copy and paste from your browser.
"url": "YOURURLHERE"
//Cache is false so that your browser does not run an old function when you cnange your code
}, { cache: false, expiry: 7200}, function(res) {
//Blockspring APIs take in data as if it was from a spreadsheet. Needs nested arrays
//Like this: [[row1val1, row1val2],[row2val1, row2val2]...]
//Example from Blockspring site
var orig = "[[\"name\",\"random number\"],[\"Jason\",\"150\"],[\"Don\",\"250\"],[\"Paul\",\"50\"]]"
//Add values to sheet
blockspring.runParsed("append-to-google-spreadsheet", {
//middle parameter from Google Spreadhseet URL
//https://docs.google.com/spreadsheets/d/FILE_ID/edit?usp=sharing
"file_id": 'YOURIDHERE',