Skip to content

Instantly share code, notes, and snippets.

Raine Revere raineorshine

Block or report user

Report or block raineorshine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@raineorshine
raineorshine / google-analytics-embed.js
Last active May 3, 2019
Google Analytics example
View google-analytics-embed.js
// 1. basic tracking code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35559116-1']);
_gaq.push(['_setDomainName', 'collegecoding.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
@raineorshine
raineorshine / Web Dev Shell Commands.sh
Last active Dec 11, 2015
Common Linux commands that I use when developing web applications.
View Web Dev Shell Commands.sh
# stylus compile & watch
stylus public/style/main.styl -w &
npm outdated # nicest way to list installed modules
npm ls # list installed modules & dependencies
npm ls -g # list globally installed node modules
npm update # check for updated versions of modules in the current package
npm view {pkg} # view a package's published metadata
npm install {pkg} --save # install the latest version of a package and add it to your package.json's dependencies
npm install {pkg} --save-dev # install and save as a devDependency
View mongo-cheat-sheet.js
/* COMMAND LINE */
mongod & // start mongo server on port 27017 by default
mongo mydb // launch mongo shell using the specified database
// importing & exporting
mongoimport -d mydb -c mycollection --jsonArray --file input.json
mongoimport -d mydb -c mycollection --headerline --type csv --file input.csv
mongoexport -d mydb -c mycollection --out output.json
/* MONGO SHELL */
View cpp-commands.md

Compile C++

g++ -Wall hello.cpp -o hello

@raineorshine
raineorshine / ActionListenerDemo.java
Last active Dec 14, 2015
Demonstrates how to hook up a function to the 'click' event of a button with addActionListener in a Swing-based Java application
View ActionListenerDemo.java
package actionlistenerdemo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// The primary class is a JFrame which can be shown when the program starts
public class ActionListenerDemo extends JFrame {
/* main is just housed inside of the primary class. It creates a new
@raineorshine
raineorshine / cheatsheet-git.sh
Last active Oct 20, 2019
Cheatsheet: git commands
View cheatsheet-git.sh
# adding and committing
git add -A # stages All
git add . # stages new and modified, without deleted
git add -u # stages modified and deleted, without new
git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
git commit --amend --no-edit # Do so without having to edit the commit message.
# remotes - pushing, pulling, and tracking
git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
git remote -v # Lists all remotes (verbose)
@raineorshine
raineorshine / recursion.java
Last active Dec 14, 2015
Java: Simple Recursion Example
View recursion.java
public class RecursionTest
{
public static int calc(int n)
{
// base case
if(n == 0)
{
return 1;
}
@raineorshine
raineorshine / loops-objects-vs-arrays.js
Last active Dec 15, 2015
Looping over Objects vs Arrays in Javascript (Beginner)
View loops-objects-vs-arrays.js
// looping over an array
var fruit = ["Mango", "Guanabana", "Mamoncino", "Piña"];
for(var i=0; i<fruit.length; i++) {
console.log(fruit[i]);
}
// looping over an object
var students = {
// key : value
// access a value with object[key]
@raineorshine
raineorshine / equiv-conditionals.java
Created Mar 20, 2013
Logic Practice: Equivalent Conditionals (beginner)
View equiv-conditionals.java
// all three of the below code snippets are equivalent!
// #1: If you notice the body of your 'if' is empty but your else has code, then convert it to #2
if(A && B)
{
// do nothing
}
else
{
doSomething();
@raineorshine
raineorshine / enums-vs-strings.java
Last active Dec 15, 2015
Enums vs Strings in Java (Beginner/Intermediate)
View enums-vs-strings.java
/*
Enums are mostly for internal purposes. Think of it as a way to make your job as a developer
easier when you have a few predefined values and you don't want to have to remember obscure codes.
Let's say you have three different states in your program: 0 means INACTIVE, 1 means PENDING, and 2
means ACTIVE.
*/
// You could keep track of the state with an integer like so:
int programState = 1; // PENDING
You can’t perform that action at this time.