Skip to content

Instantly share code, notes, and snippets.

View remzmike's full-sized avatar
💭
Where's your code? ¯\_(ツ)_/¯

remzmike

💭
Where's your code? ¯\_(ツ)_/¯
View GitHub Profile
-- throttling/scheduling function wrappers
-- v01 - 4/26/2013 3:08:51 PM - tested in lua 5.1 and 5.2
-- todo: allow optional string keys
local _registry = {}
function run_many(count, fn, ...)
return internal_run({fn=fn, count=count}, ...)
end
@remzmike
remzmike / fwtext.py
Last active September 24, 2018 16:06
fullwidth unicode text generator
#-- https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#
#
# Range U+FF01-FF5E reproduces the characters of ASCII 21 to 7E as fullwidth forms,
# that is, a fixed width form used in CJK computing. This is useful for typesetting Latin characters in a CJK environment.
# U+FF00 does not correspond to a fullwidth ASCII 20 (space character), since that role is already fulfilled by U+3000 "ideographic space."
#
# unichr(0xFEE0 + ord(asciichar))
import sys
@remzmike
remzmike / guidconvert.md
Last active September 24, 2018 16:06
Convert from Oracle to Microsoft GUID, reversing first half endianness. (2010)

Convert from Oracle to Microsoft GUID, reversing first half endianness.

With struct packing:

def convert(guidstring):
  ms = guidstring.replace('-','').replace('{','').replace('}','')
  a,b,c,d = ms[0:8], ms[8:12], ms[12:16], ms[16:]
  x = struct.pack('<LHH',int(a,16),int(b,16),int(c,16)).encode('hex')  
 return (x+d).upper()
@remzmike
remzmike / guidconvert.py
Last active September 24, 2018 16:05
convert between microsoft and oracle guids, reversing first-half endian-ness (2010)
# 10/25/2010
import sys, struct
def change(l):
return ''.join( ['{0}{1}'.format(a,b) for a,b in zip(l,l[1:])[::2][::-1]] )
def convert(guidstring):
ms = guidstring.replace('-','').replace('{','').replace('}','').upper()
return change(ms[0:8]) + change(ms[8:12]) + change(ms[12:16]) + ms[16:]
@remzmike
remzmike / asp-net-file-uploads-advanced.cs
Last active April 17, 2017 15:32
HttpPostedFile::SaveAs in .net 1, 2 and 4
// HttpPostedFile::SaveAs
// from .net 1.0
public void SaveAs(string filename)
{
FileStream fileStream = new FileStream(filename, 2);
try
{
if (this._stream.DataLength > 0)
{
@remzmike
remzmike / a.cs
Created May 13, 2017 14:06
IndexOf vs Dictionary
public void Old(string s) {
var matchCount = 0;
for (var i=0;i<4000;i++) {
var key = String.Format(",{0},", i);
if (s.IndexOf(key) >= 0) {
matchCount++;
}
}
Console.WriteLine(String.Format("s matches: {0}", matchCount));
}
@remzmike
remzmike / _.js
Last active May 21, 2017 15:07
vue jquery id confusion
// vue jquery id confusion
//
// in a template taking prop 'button_id'
// bound with: v-bind:id=button_id (or v-bind="{id:button_id}")
this.$props.button_id
// "#button1"
$(event.target).prop('id')
// "#button1"
@remzmike
remzmike / wee.js
Created June 16, 2017 15:02
javascript dates in 2017 lol
new Date(2017,04,01)
// Mon May 01 2017 00:00:00 GMT-0400 (Eastern Daylight Time)
new Date("2017-04-01")
// Fri Mar 31 2017 20:00:00 GMT-0400 (Eastern Daylight Time)
new Date("2017","04","1")
// Mon May 01 2017 00:00:00 GMT-0400 (Eastern Daylight Time)
new Date("2017",4,"01");
// Mon May 01 2017 00:00:00 GMT-0400 (Eastern Daylight Time)
new Date("2017",3,"01");
// Sat Apr 01 2017 00:00:00 GMT-0400 (Eastern Daylight Time)
@remzmike
remzmike / _.cs
Created June 21, 2017 19:57
60 second where clause builder
// 60 second where clauses
string Or(string a, string b)
{
return "( " + a + " OR " + b + " )";
}
string And(string a, string b)
{
return "( " + a + " AND " + b + " )";
@remzmike
remzmike / _.cs
Last active June 25, 2017 14:31
codified where clauses with alchemysharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using AlchemySharp; // https://github.com/FogCreek/AlchemySharp
namespace WhereClauseTest
{
class Program