Skip to content

Instantly share code, notes, and snippets.

Check out

Adi SK skadimoolam

Check out
View GitHub Profile
posener /
Last active Sep 18, 2021
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

View hex2ascii2hex.js
//Thanks stackoverflow
function a2hex(str) {
var arr = [];
for (var i = 0, l = str.length; i < l; i ++) {
var hex = Number(str.charCodeAt(i)).toString(16);
return arr.join('');
getify / gist:7ae82fdc2e86bf66bcba
Last active Mar 11, 2021
List of ES6 books either out or in progress...
View gist:7ae82fdc2e86bf66bcba
ebidel / unregistered_custom_elements.bookmarklet.js
Last active May 30, 2019
Logs any custom elements on a page that are not registerd (e.g. missing an HTML import)
View unregistered_custom_elements.bookmarklet.js
javascript:(function(){function isUnregisteredCustomElement(el){if(el.constructor==HTMLElement){console.error("Found unregistered custom element:",el);return true;}return false;}function isCustomEl(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}var allCustomElements=document.querySelectorAll('html /deep/ *');{return isCustomEl(el);});var foundSome=false;for(var i=0,el;el=allCustomElements[i];++i){if(isUnregisteredCustomElement(el)){foundSome=true;}}if(foundSome){alert('Oops: found one or more unregistered custom elements in use! Check the console.');}else{alert('Good: All custom elements are registered :)');}})();
danharper / background.js
Last active Sep 18, 2021
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
View background.js
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
Xeoncross / ajax.js
Last active Apr 21, 2021
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
View ajax.js
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
* @param string url
* @param object callback
* @param mixed data
* @param null x
function ajax(url, callback, data, x) {
try {
Mins /
Last active Sep 2, 2021
Automating mysql_secure_installation
aptitude -y install expect
// Not required in actual script
SECURE_MYSQL=$(expect -c "
set timeout 10
faisalman / baseConverter.js
Last active Aug 26, 2021
Convert From/To Binary/Decimal/Hexadecimal in JavaScript
View baseConverter.js
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* Copyright 2012-2015, Faisalman <>
* Licensed under The MIT License
iros /
Created Aug 22, 2012
Documenting your REST API


<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

View slugify.js
function slugify(text)
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text