Skip to content

Instantly share code, notes, and snippets.

macinnir macinnir

Block or report user

Report or block macinnir

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
@macinnir
macinnir / trie_tree.go
Created Jun 14, 2019 — forked from lidashuang/trie_tree.go
trie tree with golang
View trie_tree.go
package main
import (
"fmt"
)
const (
MaxNum = 26 // a-z count
Aval = 97 // a ansi value
)
View quadratic.go
package main
import (
"fmt"
"math"
)
func quadratic(a, b, c float64) (d, e float64) {
View CSharpDiagnostics.cs
// Framework version
Console.Write(typeof(string).Assembly.ImageRuntimeVersion);
// C# Version
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /?
@macinnir
macinnir / dynamically
Last active Dec 8, 2015
Dynamically call method on object in C#
View dynamically
var t = model.GetType();
var mth = t.GetMethod(action);
if (mth != null)
{
try
{
mth.Invoke(model, new object[] { });
}
catch(AmbiguousMatchException)
{
View bash-profile.sh
#!/bin/bash
# System-wide .profile for sh(1)
# A portion taken from http://vvv.tobiassjosten.net/git/add-current-git-branch-to-your-bash-prompt/
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset=`tput sgr0`
c_user=`tput setaf 2; tput bold`
c_path=`tput setaf 4; tput bold`
c_git_clean=`tput setaf 2`
c_git_dirty=`tput setaf 1`
else
@macinnir
macinnir / object-array-loop-fail.js
Created Mar 12, 2015
Extending Object and Array and the unexpected results in looping
View object-array-loop-fail.js
/**
* Object/Array native objects being extended via prototype produces unexpected results when
* when looping through objects/arrays respectively.
* @author Rob MacInnis
* @see http://stackoverflow.com/questions/10695506/adding-function-to-object-prototype-causes-function-to-show-up-in-all-for-x-in
*/
require('colors');
// Extending a native JS object
@macinnir
macinnir / 0_reuse_code.js
Created Apr 25, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@macinnir
macinnir / JQuery Validation
Created Aug 31, 2012
General application of JQuery Validate
View JQuery Validation
/* Method for validating Zip Code */
/* Requires Jquery-latest and Jquery-Validation plugin (http://docs.jquery.com/Plugins/Validation) */
$.validator.addMethod('client_zip_cb',
function(value){
/* Apply validation code */
return value == '99999'
},
'Please enter 99999 for the zip code!'
);
@macinnir
macinnir / KendoUIJS
Last active Oct 9, 2015
Kendo UI Example
View KendoUIJS
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="js/kendo.web.min.js"></script>
<style type="text/css">
<!--
.active { display: list-item; }
.inactive { display: none; }
You can’t perform that action at this time.