Skip to content

Instantly share code, notes, and snippets.

View peterdemartini's full-sized avatar
😎
being awesome

Peter DeMartini peterdemartini

😎
being awesome
View GitHub Profile
mkdir -p ~/tmp/devices
cd ~/tmp/devices
npm init -y
npm install meshblu-blink1
cd meshblu-blink1
echo '{
"uuid": "370b01b5-1927-44a1-a30b-2147430a4fae",
"token": "561bbf70d2aa2db62d22d8f85c19155c52184995",
"server": "meshblu.octoblu.com",
"port": 443
node_modules/.bin/browserify -t coffeeify --extension=".coffee" -s GatebluWebsocket index.coffee > public/gateblu-websocket.js && hs -p 3444
@peterdemartini
peterdemartini / gist:cbf96a5d647fb47cb215
Created November 19, 2014 05:05
Sublime Vintage Mode Cheatsheet ( Not finished )

Sublime Vintage Mode Cheatsheet

Movements

Key(s) Command(s)
h, j, k, l left, up, down, right
0, ^, $ beginning, first character, end of line
f, F go to next occurrence of character on current line
gg, G, : go to first line, last line, line number
@peterdemartini
peterdemartini / follow_twitter_users.js
Last active August 29, 2015 14:03
Unfollow and Follow Twitter Users. Simply load a page of twitter followers and type this into the console.
$('.user-actions-follow-button').filter(function(){ return $(this).find('.follow-text:visible').size(); }).sort(function() {
return .5 - Math.random();
}).slice(0, 1000).click();
@peterdemartini
peterdemartini / jshintrc.txt
Last active June 12, 2019 20:08
My .jshintrc for Node.js and clean JavaScript
{
"passfail": false, // Stop on first error
"maxerr": 100, // Maximum error before stopping
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"browser": true, // Standard browser globals e.g. `window`, `document`.
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
"curly": false, // Require {} for every new block or scope.
"eqeqeq": true, // Require triple equals i.e. `===`.
@peterdemartini
peterdemartini / new_gist_file.php
Created March 13, 2014 16:19
SugarCRM Duplicate Bean
<?php
function duplicate_bean($bean){
$exclude = array(
'id',
'date_entered',
'date_modified'
);
$newbean = new $bean->object_name;
foreach($bean->field_defs as $def){
@peterdemartini
peterdemartini / new_gist_file.php
Created March 4, 2014 18:44
SugarCRM Custom JSON API Entry Point
<?php
class CustomAPI {
var $inbound = false;
public function __construct(){
$this->inbound = $this->parse_inbound_json();
}
public function get_inbound(){ return $this->inbound; }
@peterdemartini
peterdemartini / sugar_script.php
Created December 20, 2013 16:54
SugarCRM entryPoint in the root of Sugar. Great for scripts.
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
chdir(realpath(dirname(__FILE__)));
require_once('include/entryPoint.php');
//Running with SugarCRM
//Custom Code Goes below here
@peterdemartini
peterdemartini / sugar_send_email.php
Created December 20, 2013 16:47
SugarCRM Send Email via PHP
<?php
function send_report_email($subject, $body, $emails){
require_once('include/SugarPHPMailer.php');
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
@peterdemartini
peterdemartini / sugarcrm_convert_date.php
Created December 12, 2013 21:56
SugarCRM Convert Date from DB to User Format
<?php
global $timedate;
$timedate->swap_formats(date('Y-m-d'), $timedate->dbDayFormat, $timedate->get_date_format());