Skip to content

Instantly share code, notes, and snippets.

View MattiasFestin's full-sized avatar

Mattias Festin MattiasFestin

View GitHub Profile
@MattiasFestin
MattiasFestin / model.rs
Last active April 10, 2020 14:08
diesel custom types
#[derive(Queryable, Insertable, AsChangeset)]
pub struct Transaction {
pub id: uuid::Uuid,
pub created: SystemTime,
pub modified: SystemTime,
pub deleted: Option<SystemTime>,
pub row_version: i64,
pub transaction_type_id: i64,
pub transaction_direction_id: i64,
Add-Type -AssemblyName System.Speech; $ss = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer; $ss.Rate = 1.2; $ss.Speak('There was a catastrophic cyber attack recently. All the data was encrypted.... The government is still looking for the hacker. They think he ran some ware.');
Add-Type -AssemblyName System.Speech; $ss = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer; $ss.Speak('Do you want some up dog?'); $ss.SelectVoice('Microsoft Zira Desktop') ; $ss.Speak('What is up dog?'); $ss.SelectVoice('Microsoft David Desktop'); $ss.Speak('Nothing much, how about you'); $ss.SelectVoice('Microsoft Zira Desktop') ; $ss.Speak('Fuck you Dave!');
@MattiasFestin
MattiasFestin / boombox.ascii
Last active April 4, 2018 16:11
Ascii arts
░░█▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
██▀▀▀██▀▀▀▀▀▀██▀▀▀██
█▒▒▒▒▒█▒▀▀▀▀▒█▒▒▒▒▒█
█▒▒▒▒▒█▒████▒█▒▒▒▒▒█
██▄▄▄██▄▄▄▄▄▄██▄▄▄██
█ ██ ██▀███ ▒█████ ▄████▄ ██ ▄█▀ ▐██▌
██ ▓██▒ ▓██ ▒ ██▒▒██▒ ██▒▒██▀ ▀█ ██▄█▒ ▐██▌
▓██ ▒██░ ▓██ ░▄█ ▒▒██░ ██▒▒▓█ ▄ ▓███▄░ ▐██▌
@MattiasFestin
MattiasFestin / AbstractManager.js
Last active February 11, 2016 07:42
memmory safe AbstractManager
//Dependency: https://gist.github.com/MattiasFestin/e5e92d5ae5e2b4bf89c3
Ext.override('Ext.AbstractManager', {
constructor: function(config) {
Ext.apply(this, config || {});
/**
* @property {Ext.util.HashMap} all
* Contains all of the items currently managed
*/
if (typeof window.WeakMap === 'function') {
@MattiasFestin
MattiasFestin / weakhashmap.js
Last active September 2, 2015 06:56
WeakHashMap for ext.js
Ext.define('Ext.util.WeakHashMap', {
mixins: {
observable: 'Ext.util.Observable'
},
generation: 0,
/**
* Creates new HashMap.
@MattiasFestin
MattiasFestin / str-pad.es6
Created May 11, 2015 09:18
String padding (Requires propper tail calls)
let padLeft = (value, char, n) => n - value.length > 0 ? padLeft(char + value, char, n-1) : value;
let padRight = (value, char, n) => n - value.length > 0 ? padRight(value + char, char, n-1) : value;
@MattiasFestin
MattiasFestin / modPow.es6
Last active August 29, 2015 14:20
Power modulo (Requires propper tail calls)
let modPow = (b, e, m, value = 1) => {
b = b % m;
if (e % 2 === 1) {
value = (value * b) % m;
}
return e <= 1 ? value : modPow(b * b, e >> 1, m, value);
};
@MattiasFestin
MattiasFestin / spawn-webworker.es6
Created May 11, 2015 09:14
Spawn webworker with function or js code in string
let spawn = (...args) => {
var src = args.map(function (x) {
return typeof x === 'function' ? '((' + x.toString() + ').call(this));' : x;
}).join(';');
return new Worker(
window.URL.createObjectURL(
new Blob([src])
)
);
@MattiasFestin
MattiasFestin / uuid.es6
Created May 11, 2015 09:12
a small simple uuid function for javascript
let Uuid = () => {
let r = (s) => {
let p = (Math.random().toString(16)+"000000000").substr(2,8);
return s ? "-" + p.substr(0,4) + "-" + p.substr(4,4) : p;
};
return r() + r(1) + r(1) + r();
};