Skip to content

Instantly share code, notes, and snippets.

View StolenThunda's full-sized avatar
🏠
Working from home

Antonio R Moses StolenThunda

🏠
Working from home
View GitHub Profile
@StolenThunda
StolenThunda / zsh_autoinstall.sh
Last active July 15, 2020 19:03
First version of ZSH auto installer
#!/bin/bash
# According to: https://medium.com/@shivam1/make-your-terminal-beautiful-and-fast-with-zsh-shell-and-powerlevel10k-6484461c6efb
# Very simple ZSH install w/ no error checking
# Includes:
# - nerd fonts
# - powerline10k theme
# - auto-suggestion/syntax highlighting plugins
# - etc
#
# Installing from command line:
var jqry=document.createElement('script');
jqry.src="https://code.jquery.com/jquery-3.3.1.min.js";
document.getElementsByTagName('head')[0].appendChild(jqry);
list=[];
$('.sm-scorename a').each(function(){
list.push(this.text + '\t' + $(this).parents('.sm-score').data('score') );
});
newList = list.reverse();
list = newList.join('\n');
document.body.focus();
@StolenThunda
StolenThunda / insert_replace_txt.js
Last active March 23, 2019 03:59
Adds text into a text area at the user's cursor position or replaces selected text. (https://stackoverflow.com/questions/11076975/insert-text-into-textarea-at-cursor-position-javascript)
$( 'input[type=button]' ).on('click', function(){
var cursorPosStart = $('#text').prop('selectionStart');
var cursorPosEnd = $('#text').prop('selectionEnd');
var v = $('#text').val();
var textBefore = v.substring(0, cursorPosStart );
var textAfter = v.substring( cursorPosEnd, v.length );
$('#text').val( textBefore+ $(this).val() +textAfter );
});
@StolenThunda
StolenThunda / local_vars_dump.php
Created February 26, 2019 04:36
Get list of all user-defined vars
<?php
// list of keys to ignore (including the name of this variable)
$ignore = array('GLOBALS', '_FILES', '_COOKIE', '_POST', '_GET', '_SERVER', '_ENV', 'ignore');
// diff the ignore list as keys after merging any missing ones with the defined list
$vars = array_diff_key(get_defined_vars() + array_flip($ignore), array_flip($ignore));
// should be left with the user defined var(s) (in this case $testVar)
var_dump($vars);
@StolenThunda
StolenThunda / print_var_name
Last active February 1, 2019 02:26
Print string name of var
function print_var_name($var) {
\!h foreach($GLOBALS as $var_name => $value) {
if ($value === $var) {
return $var_name;
}
}
return false;
}
@StolenThunda
StolenThunda / cloudSettings
Last active May 15, 2019 13:19
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-02-18T19:04:54.725Z","extensionVersion":"v3.2.5"}
function dm_view($view, $path, data=array() ) {
$CI =& get_instance();
$tp = $CI->load->_ci_view_path;
$CI->load->_ci_view_path = $path;
$out = $CI->load->view($view,$data,true);
$CI->load->_ci_view_path = $tp;
<?php
/**
source: http://php.net/manual/en/function.scandir.php
Thanks to gambit_642 AT hotmailDOTcom 4 years ago
Needed something that could return the contents of single or multiple directories, recursively or non-recursively,
for all files or specified file extensions that would be
accessible easily from any scope or script.