Skip to content

Instantly share code, notes, and snippets.

(function () {
// Check if the script is already loaded
if (document.getElementById("mrh-proxy-script")) {
console.log("Script already loaded, skipping...");
return;
}
// Add a float button to the page to show that the script is running
var floatButton = document.createElement("div");
floatButton.style.position = "fixed";
@thachnuida
thachnuida / importChildModules.py
Last active April 11, 2018 09:02
Import child module in child folder for js
import sublime
import sublime_plugin
import os
import re
class ImportChildModulesCommand(sublime_plugin.TextCommand):
def replace_module_name(self, m):
return m.group(2).upper()
@thachnuida
thachnuida / requireJsFiles.py
Created April 11, 2018 07:16
Auto insert import other js files in current folder to current file
# Add to key binding { "keys": ["ctrl+1"], "command": "require_js_files"}
import sublime
import sublime_plugin
import os
class RequireJsFilesCommand(sublime_plugin.TextCommand):
def run(self, edit):
current_folder = os.path.dirname(self.view.file_name())
current_file_name = os.path.basename(self.view.file_name())
@thachnuida
thachnuida / flat-object.js
Last active October 12, 2016 04:05
Flat object
var a = {
b: {
c: {
d: {
e: 'text 1'
}
}
},
f: 'text'
};
@thachnuida
thachnuida / 2-letters 3-letters country codes
Created April 20, 2016 08:32
2-letters 3-letters country codes
// http://country.io/iso3.json
{
BD: "BGD",
BE: "BEL",
BF: "BFA",
BG: "BGR",
BA: "BIH",
BB: "BRB",
WF: "WLF",
@thachnuida
thachnuida / Restangular-Upload-File.js
Created February 6, 2016 03:51
Restangular Upload File
var fd = new FormData();
fd.append('file', vm.selectedLogo);
Restangular.one('/api/admin/settings/logo')
.withHttpConfig({transformRequest: angular.identity})
.customPOST(fd, '', undefined, {'Content-Type': undefined})
.then(function() {
getLogo();
});
@thachnuida
thachnuida / Sublime text 3 build from bat file
Created February 6, 2016 02:31
Go to Tools -> Build System -> New Build System
{
"cmd": ["C:\\Users\\Thach Nguyen\\build.bat"]
}
@thachnuida
thachnuida / fb-post-preview.directive.js
Last active March 7, 2019 12:43
Angular directive to embed Facebook public post
(function () {
'use strict';
/**
* @desc Direictive to embed facebook post
* @example <fb-post-preview data-href="vm.postUrl"></fb-post-preview>
*/
angular
.module('fbDirective')
.directive('fbPostPreview', fbPostPreview);
@thachnuida
thachnuida / imgOrientation.js
Last active July 4, 2019 12:02
Angularjs Directive to rotate image base on EXIF orientation value
/* global EXIF */
'use strict';
// Require library: https://github.com/jseidelin/exif-js
// Require Jquery (If not have jquery you must handle DOM by native js code)
/**
@description this directive auto rotate image by css base on image orientation value
Check the example of image orientation here:
https://github.com/recurser/exif-orientation-examples
@example
/**
* @fileOverview
* @author <a href="mailto:[email protected]">Oleg Varaksin</a>
* @version 0.2
*/
/**
* Whiteboard designer class for element drawing.
* @class
* @param witeboardConfig whiteboard's configuration {@link WhiteboardConfig}