Skip to content

Instantly share code, notes, and snippets.

View DavidGoussev's full-sized avatar

David Goussev DavidGoussev

View GitHub Profile
@DavidGoussev
DavidGoussev / connectFour.js
Created June 23, 2016 22:01
ConnectFour_GameChecking Method Signatures
function chkLine(a,b,c,d) {
// Check first cell non-zero and all cells match
return ((a != 0) && (a ==b) && (a == c) && (a == d));
}
function chkWinner(bd) {
// Check down
for (r = 0; r < 3; r++)
for (c = 0; c < 7; c++)
if (chkLine(bd[r][c], bd[r+1][c], bd[r+2][c], bd[r+3][c]))
@DavidGoussev
DavidGoussev / Jquery_getAPI.js
Created June 14, 2016 15:10
Hackathon get API data
function ($) {
$('button').on('click', function () {
// remove resultset if this has already been run
$('.content ul').remove();
// add spinner to indicate something is happening
$('<i class="fa fa-refresh fa-spin"/>').appendTo('body');
// get selected zip code from selectbox
var zip = $('select option:selected').text().substring(1, 6);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
define(["require", "exports"], function (require, exports) {
/**
* Helper to use the Command Line Interface (CLI) easily with both Windows and Unix environments.
* Requires underscore or lodash as global through "_".
*/
var Cli = (function () {
function Cli() {
}
/**
* Execute a CLI command.

#Node - Processes To launch an external shell command or executable file you can use the child_process. Apart from command line arguments and environment variables you cannot communicate with the process using child_process.exec. However you can use child_process.spawn to create a more integrated processes.

##Executing Child Processes

###To launch an external shell command

var child_process = require('child_process');
var exec = child_process.exec;
@DavidGoussev
DavidGoussev / find_duplicates.js
Created June 1, 2016 00:13
Find Duplicates in Array [js]
function dedupe(arr) {
var i, j = arr.length, deduped = [];
for (i=0; i < j; i++) {
if (deduped.indexOf(arr[i]) === -1 && arr.indexOf(arr[i], i+1) !== -1) {
deduped.push(arr[i]);
}
}
return deduped;
}
# Word Correction Take-Home
Write a program in JavaScript that reads a large list of English words (e.g. from /usr/share/dict/words on a unix system) into memory, and then reads words from stdin, and prints either the best spelling correction, or "NO CORRECTION" if no suitable correction can be found.
The program should print "> " as a prompt before reading each word, and should loop until killed.
For example:
$node ./spellcorrecter.js
> sheeeeep
@DavidGoussev
DavidGoussev / post.html
Last active March 21, 2016 03:59
adding tags to jekyll blog
<ul class="tags">
{% for tag in page.tags %}
<li><a href="{{site.baseurl}}tags#{{tag}}" class="tag">{{ tag }}</a></li>
{% endfor %}
</ul>
@DavidGoussev
DavidGoussev / Firebase + AngularJS Presence
Created March 8, 2016 05:48 — forked from simpulton/Firebase + AngularJS Presence
A real-time presence service using Firebase and AngularJS.
app.controller('MainCtrl', ['$scope', 'PresenceService', function ($scope, PresenceService) {
$scope.totalViewers = 0;
$scope.$on('onOnlineUser', function(){
$scope.$apply(function () {
$scope.totalViewers = PresenceService.getOnlineUserCount();
});
});
}]);
@DavidGoussev
DavidGoussev / gist:7916cb55ae331758ecd5
Created January 25, 2016 03:20 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote