Skip to content

Instantly share code, notes, and snippets.

Avatar
😎

misha sawangwan msawangwan

😎
View GitHub Profile
View yaml_validator.py
#!/usr/bin/env python3
'''
simple yaml file validator, reports any syntax errors.
'''
import sys
import argparse
# pylint: disable=import-error
@msawangwan
msawangwan / download_gist.py
Created Jan 7, 2019
[python][gist][api] tool for downloading all the files in a single gist (by gist id)
View download_gist.py
#!/usr/bin/env python
import sys
import requests
api = 'https://api.github.com'
gist_id = '' # YOUR ID HERE, COULD BE PASSED IN AS AN ARG
print('fetching latest revisions ..')
@msawangwan
msawangwan / git-push-repos.sh
Last active Jun 28, 2017
[git][bash] automate 'git push' to all remote references
View git-push-repos.sh
#!/bin/bash
# author: misha '@mad.meesh' sawangwan
# i got tired of typing 'git push <remote_repo>' for
# each of the remotes referenced by my local repository so
# i wrote up a quick lil' script to automate the process.
#
# it's pretty simple and likely contains bugs but it does
@msawangwan
msawangwan / git_add_commit_push.sh
Created Mar 7, 2017
[bash] git auto add-commit-push
View git_add_commit_push.sh
#!/bin/bash -x
REQ_ARGS=2
BAD_ARGS_EXIT=65
if [ $# -ne $REQ_ARGS ]; then
echo
echo "usage: `basename $0` REPOSITORY BRANCH"
echo
exit $BAD_ARGS_EXIT
@msawangwan
msawangwan / Wait.cs
Last active Feb 10, 2017
[unity3d][csharp] unity helper class that caches coroutine objects to hopefully help with constantly allocating on each iteration of the routine
View Wait.cs
using UnityEngine;
using System.Collections.Generic;
/// <summary>
/// memoize shit, it's healthy
/// </summary>
namespace UnityCore {
public static class Wait {
private const string defaultCondLabel = "default cond";
private const float defaultIntervalInSeconds = 1.0f;
@msawangwan
msawangwan / SwipeManagerImproved.cs
Last active Nov 5, 2018
[csharp][unity] simple swipe controller
View SwipeManagerImproved.cs
/*
In the original source, there are two unnecessary magnitude calculations, calculated
each frame. This isn't the most performant choice as to calculate magnitude one must divide
by the sqrRoot of the sum of each component squared, so
this may improve performance, however slight.
Also removed was a redundant calculation where the original author determined
delta x and y, once for checking if a swipe happened and once more to determine the sign.
Essentially, all these removed operations, were calculating the same thing, so all the redundant
@msawangwan
msawangwan / csharp-keywords.md
Last active Oct 3, 2016
[csharp][cheat sheet] list of all csharp keywords
View csharp-keywords.md

complete list of csharp keywords



  • A
    • abstract
    • add
    • as
@msawangwan
msawangwan / genpasswd.sh
Last active Oct 3, 2016
[bash][shell] password generator
View genpasswd.sh
#!/bin/bash
#+ Password Generator
#+ Author: misha@sawangwan.me
#+ Utilizes the entropy pool to generate a password. If no length
#+ is specified, a default length of 20 is used.
#+ Execute with './' prefix or add to PATH (recommended).
#+ Usage:
@msawangwan
msawangwan / csharp-singletons.md
Last active Oct 3, 2016
[csharp][software design patterns] various implementations of the singleton pattern in csharp
View csharp-singletons.md

#Implementations of the Singleton in C-Sharp

##As written by Jon Skeet

####Note:

Jon's personal preference is solution 4.

*Use solution 2 over solution 4 in cases where you need to be able to call other static methods without triggering initialization or you need to know

You can’t perform that action at this time.