Skip to content

Instantly share code, notes, and snippets.

View msawangwan's full-sized avatar
😎

misha sawangwan msawangwan

😎
View GitHub Profile
@msawangwan
msawangwan / csharp-singletons.md
Last active October 3, 2016 18:14
[csharp][software design patterns] various implementations of the singleton pattern in csharp

#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

@msawangwan
msawangwan / genpasswd.sh
Last active October 3, 2016 18:16
[bash][shell] password generator
#!/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-keywords.md
Last active October 3, 2016 18:13
[csharp][cheat sheet] list of all csharp keywords

complete list of csharp keywords



  • A
    • abstract
    • add
  • as
@msawangwan
msawangwan / SwipeManagerImproved.cs
Last active April 11, 2022 04:31
[csharp][unity] simple swipe controller
/*
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 / Wait.cs
Last active February 10, 2017 00:13
[unity3d][csharp] unity helper class that caches coroutine objects to hopefully help with constantly allocating on each iteration of the routine
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 / git_add_commit_push.sh
Created March 7, 2017 07:39
[bash] git auto add-commit-push
#!/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 / git-push-repos.sh
Last active June 28, 2017 16:26
[git][bash] automate 'git push' to all remote references
#!/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 / download_gist.py
Created January 7, 2019 21:04
[python][gist][api] tool for downloading all the files in a single gist (by gist id)
#!/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 ..')
#!/usr/bin/env python3
'''
simple yaml file validator, reports any syntax errors.
'''
import sys
import argparse
# pylint: disable=import-error
@msawangwan
msawangwan / index.haml
Created September 26, 2022 01:35
Take Me On
#btnwrap
%button#button{:onclick => "takeMeOn()"}
%i.fas.fa-play.play
%i.fas.fa-pause.pause
%audio#aha{:controls => ""}
%source{:src => "https://puu.sh/GeJzb/75c457c7df.mp3", :type => "audio/mpeg"}
%input{:type => "checkbox"}/
#outer