Skip to content

Instantly share code, notes, and snippets.

View xealgo's full-sized avatar

Jason Welch xealgo

View GitHub Profile
var stagePos = smClient.felt.script.position;
var pos = {
top : stagePos('top',-200),
left: 0
}
var index = 0;
var cards = _.clone(smClient.game.cards);
for(var card, f = 0; f < action.finalHand.length; f++) {
@xealgo
xealgo / defaults.js
Created August 29, 2015 22:43
lodash / underscore - set default parameters while ignoring unknown vars.
var Person = function(params) {
this.name = "";
this.age = 0;
this.gender = "na";
_.extend(this, _.pick(params, _.keys(this)));
};
var jason = new Person({
name: "Jason",
@xealgo
xealgo / bacon-github.js
Last active January 10, 2017 09:14
basic bacon + api request
// bacon.fromPromise wrapper
let request = function(data) { return Bacon.fromPromise($.ajax(data.url)); }
// userdata event stream - sends github api request each time the username text field looses focus.
let userdata = $("#username").asEventStream("blur").map(function(event) {
let user = $(event.target).val();
return {url: `https://api.github.com/users/${user}`};
}).flatMap(request).log("user stream");
// handle the data response that "request" made.
@xealgo
xealgo / mapper.go
Last active May 10, 2017 21:35
Simple struct to map[string]interface{}
package search
import (
"reflect"
"strings"
)
// Build creates a map[string]interface object from a given
// struct based on tags.
func Build(tagName string, model interface{}) map[string]interface{} {

Jason Welch

Full career history.

Kyani, Idaho Falls, ID

Senior Software Engineer

Jan 2016 - Present

  • Develop microservices, workers, and tools using Golang.
  • Develop API’s, SDK’s and integrations.
  • Create and maintain documentation and guides.
@xealgo
xealgo / pre-commit
Last active June 28, 2017 06:57
git pre-commit
#!/usr/bin/env ruby
FORBIDDEN = [
/debugger/i,
/fuck/i,
/shit/i,
/bitch/i,
/wtf/i,
/fmt.Println/i,
/fmt.Printf/i,
@xealgo
xealgo / regex-go.md
Last active October 6, 2017 20:30
Javascript regex for matching Go code

func (ab *

([func]{1,} \([a-z]{2} \*)

Note: just change {2} to whatever length your var is.

Example:

func (hw *HelloWorld) DoSomething() {
@xealgo
xealgo / permutation.go
Last active September 4, 2017 06:54
checker permutation of a-z in O(n) time
// IsPermutation checks permutations in strings of a-z in O(n) time.
// O(n+n) since both a & b must be the same length.
func IsPermutation(a, b string) bool {
al, bl := len(a), len(b)
if al != bl {
return false
}
var checker [2]int
@xealgo
xealgo / compression.go
Last active September 26, 2018 07:38
solution for withgoogle.com advanced challenge number 1
///////////////////////////////////////////////////////
// solution for the With Google code challenge.
// https://techdevguide.withgoogle.com/paths/advanced/compress-decompression/#code-challenge
// by xealgo
//
// TODO: currently doesn't allow for numbers to be treated as string values,
// only to denote repetitions as per the rule:
// * Digits are only to represent amount of repetitions.
// but adding it would be pretty trivial though.
///////////////////////////////////////////////////////