Skip to content

Instantly share code, notes, and snippets.

View mralexho's full-sized avatar
💭
☕️

Alex Ho mralexho

💭
☕️
  • New York City Economic Development Corporation
  • New York
View GitHub Profile
#!/bin/bash
# Begin Standard 'imports'
set -e
set -o pipefail
gray="\\e[37m"
blue="\\e[36m"
red="\\e[31m"
@mralexho
mralexho / spacing.patch
Created July 7, 2021 20:42
adds responsive spacing to bulma
--- node_modules/bulma/sass/helpers/spacing.sass 1985-10-26 04:15:00.000000000 -0400
+++ patches/spacing.sass 2021-07-07 16:32:03.000000000 -0400
@@ -1,8 +1,8 @@
.is-marginless
- margin: 0 !important
+ margin: 0 !important
.is-paddingless
- padding: 0 !important
+ padding: 0 !important
@mralexho
mralexho / debounce.js
Created January 8, 2018 03:01
VanillaJS Debounce Func
function debounce(func, wait = 20, immediate = true) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var now = immediate && !timeout;
clearTimeout(timeout);
@mralexho
mralexho / list-mysql-table-size.sql
Created October 19, 2016 16:22
List mysql tables sorted by size; replace schema_name
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "schema_name"
ORDER BY (data_length + index_length) DESC;
@mralexho
mralexho / sort.js
Created March 1, 2016 20:46
Alpha sort
myArr.sort(function(a, b) {
var aName = a.text.toLowerCase();
var bName = b.text.toLowerCase();
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
});
var myNamespace = (function () {
var myPrivateVar = 0;
var myPrivateMethod = function (someText) {
console.log(someText); };
return {
myPublicVar: "foo",
myPublicFunction: function (bar) {
myPrivateVar++;
myPrivateMethod(bar);
} };
# find out what version of Linux (distro) you are running
$ cat /etc/*-release
# find out kernel, version number, machine hardware name
$ uname -mrs
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
this.isApproved = this.searchList(this.browser, this.version);
if(this.OS == "iPad")document.documentElement.className += ' iOS';
@mralexho
mralexho / inheritPrototype.js
Created February 24, 2015 19:42
function that makes the child object inherit from parent object
function inheritPrototype(childObject, parentObject){
var parentCopy = Object.create(parentObject.prototype);
parentCopy.constructor = childObject;
childObject.prototype = parentCopy;
}
@mralexho
mralexho / singleton.pattern.js
Last active August 29, 2015 14:15
a singleton module
var singleton = function() {
var privateVariable;
function privateFunction(x) {
...privateVariable...
}
return {
first method: function (a, b) {
...privateVariable...
},
second method: function (a, b) {