Skip to content

Instantly share code, notes, and snippets.

View cgkio's full-sized avatar

Christian Kessler IV cgkio

View GitHub Profile
@cgkio
cgkio / trim_everything_right.js
Created December 11, 2013 19:52
Regex remove everything after @ (including @)
REGEX: Trim everything up to and including =
var text = "[email protected]";
text = text.replace(/@.*$/,"");
console.log(text);
// results = "john"
@cgkio
cgkio / ssh_to_raspberry_pi.sh
Created December 10, 2013 21:21
SSH to Raspberry Pi
$ sudo ssh 192.168.2.2 -l pi
#The option “-l pi' specifies that we want to log into the Pi as the user “pi”.
# clear SSH connection issues with: $ perl -pi -e 's/\Q$_// if ($. == 5);' /var/root/.ssh/known_hosts
@cgkio
cgkio / install_blink1_tools.sh
Created December 9, 2013 22:47
Install/build blink1 command line tools
$ git clone https://github.com/todbot/blink1.git
$ cd blink1/commandline
$ make
@cgkio
cgkio / npm_create_package_json.sh
Created December 5, 2013 15:16
Interactively create a package.json file
$ npm init
@cgkio
cgkio / install_node_on_windows.sh
Created November 27, 2013 19:55
Post install (cmd.exe) command for install node.js on Windows
$ SET PATH=C:\Program Files\Nodejs;%PATH%
@cgkio
cgkio / read_json.js
Created November 25, 2013 14:49
Read local JSON file with node.js
var fs = require('fs');
var file = __dirname + '/data/filename.json';
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log('Error: ' + err);
return;
}
obj_pulseconfig = JSON.parse(data);
console.dir(data);
@cgkio
cgkio / hide_sharepoint_quick_access_panel.html
Created November 20, 2013 16:01
Hide the Quick Launch in SharePoint 2013
<!-- 1. Add a Script Editor web part to a page
2. Click EDIT SNIPPET and paste in the code (below)
3. Click Insert and the Quick Launch will disappear -->
<style type="text/css">
#sideNavBox {DISPLAY: none}
#contentBox {MARGIN-LEFT: 5px}
</style>
<!-- source: http://www.manageprojectsonsharepoint.com/blog/2013/07/25/easily-hide-the-quick-launch-in-sharepoint-2013/ -->
@cgkio
cgkio / parse_in_nodejs.js
Created November 18, 2013 17:39
Parse JavaScript SDK in Node.js
var Parse = require('parse').Parse;
Parse.initialize("Your App Id", "Your JavaScript Key");
var query = new Parse.Query(Parse.User);
query.find({
success: function(users) {
for (var i = 0; i < users.length; ++i) {
console.log(users[i].get('username'));
}
@cgkio
cgkio / parse_query.js
Created November 18, 2013 17:39
Boilerplate for basic Parse.com query (for JQM listview)
var Query = Parse.Object.extend("parse_class");
var query = new Parse.Query(Query);
//set query conditions
query.ascending("parse_item"); //sorts the results in ascending order by the score field
query.descending("score"); //sorts the results in descending order by the score field
query.limit(10); //limit to at most 10 results
query.skip(10); //skip the first 10 results
query.equalTo("playerEmail", "[email protected]");
query.notEqualTo("playerName", "Michael Yabuti");
@cgkio
cgkio / POST_to_google_spreadsheet.js
Created November 18, 2013 01:22 — forked from mhawksey/gist:1276293
POST rows into Google Spreadsheet using Google Apps Script and REST
/* Usage
1. Run the setup function (you'll need to do this twice - 1st time to grant acces to Script Properties)
2. Share > Publish as service ... set security level and enable service
3. Copy the service URL and post this in your form/script action
4. Insert column names on the DATA sheet matching the parameter names of the data you are passing
*/
function doGet(e) { // change to doPost(e) if you are recieving POST data
var ss = SpreadsheetApp.openById(ScriptProperties.getProperty('active'));
var sheet = ss.getSheetByName("DATA");