Skip to content

Instantly share code, notes, and snippets.

View divanvisagie's full-sized avatar
🦀
Rewriting it in Rust

Divan Visagie divanvisagie

🦀
Rewriting it in Rust
View GitHub Profile
@divanvisagie
divanvisagie / system.js
Last active December 10, 2015 05:48
The system function attempts to bring the C system() function to node.js with extended functionality. system() executes a command and fires an event when done that will return the command output. system has 2 events: 'data' - returns the output data of the command 'exit' - returns command exit code dependancies npm install colors Examples of the…
/* License MIT */
var spawn = require( 'child_process' ).spawn,
colors = require( 'colors' );
/*
Executes a command and fires event when done that
will return the command output
*/
function system( cmd ){
@divanvisagie
divanvisagie / Makefile
Last active February 24, 2019 13:03
A makefile template with default values for quick use for compiling C/C++ programs.
# Date Created 2013-01-02
# Adapted from http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html
# License MIT
#
# 'make depend' uses makedepend to automatically generate dependencies
# (dependencies are added to end of Makefile)
# 'make' build executable file 'mycc'
# 'make clean' removes all .o and executable files
#
@divanvisagie
divanvisagie / readme.md
Created January 4, 2013 12:32 — forked from coolaj86/how-to-publish-to-npm.md
A guide to publishing npm packages

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@divanvisagie
divanvisagie / nth_largest.cpp
Last active December 11, 2015 01:48
This is pretty much the answer( or at least mine ) to the typical CS question : Find the nth element of an array without sorting or creating a new array. I have a very nice version using templates and all the fancies , and then an Arduino version that is float specific.
#include <iostream>
using namespace std;
/* This function uses a trick with templates
to determine the size of the array */
template <class T,size_t size>
size_t arr_size( T(&)[size] ){
return size;
@divanvisagie
divanvisagie / Insane.mm
Last active December 11, 2015 03:48
I have noticed a lot of people seem to go to very unnecessary lengths to strip NSlogs (see Insane.mm) , where all thats required is something simple. Rule of Clarity: Clarity is better than cleverness - https://en.wikipedia.org/wiki/Unix_philosophy
/* who would do this ? , its insane */
#ifdef DEBUG
#define DMLog(...) NSLog(@"%s%@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#else
#define DMLog(...) do { } while (0)
#endif
@divanvisagie
divanvisagie / twits.js
Last active December 12, 2015 01:28
Scours through http://tweetping.net/ when pasted into your devtools console with the help of this lib - https://github.com/PaulKinlan/observables-js and collects all tweets processed by the site that contain longer than 10 digit text ( aimed an phone numbers ) or *@* ( aimed at emails ) whens someone is twitty enough to post them.
/* This is the observables.js library for your convenience */
(function (exports) {
"use strict";
var Observable, OnAnyChange;
OnAnyChange = function(properties, callback) {
@divanvisagie
divanvisagie / LED_Server.js
Last active May 1, 2020 08:03
Web server controlled LED on Arduino using johnny-five and the dev version of NARF( https://github.com/divanvisagie/NARF/tree/Dev ) , Five minute hack. LED is placed on pin 13.Once you get LED_Server running, the client at index.html can control the LED on your Arduino , you will have to change the GET urls in index.html if you are using it on a…
var five = require( 'johnny-five' ),
board,
narf = require( 'narf' );
board = new five.Board();
/*
Executes a command and fires event when done that
will return the command output
*/
@divanvisagie
divanvisagie / pointers.c
Last active December 13, 2015 19:28
An attempt to explain pointers
#include <stdio.h>
/* NOTE:
arr = refers to the array as a whole and/or the pointer to the first element of the array
*arr = first element of an array
*/
int main( int argc, char** argv ){
@divanvisagie
divanvisagie / db_connect.js
Created February 26, 2013 06:51
MySql database connection template for node.js
var mysql = require( 'mysql' );
var connection_details = {
host : 'localhost',
user : 'root',
password : 'password',
database : 'databasename'
};
.lit{
background:#55ee55;
}
.table-restrict {
width:18em;
height:18em;