touch ~/.zsh_functions
vim ~/.zsh_functionsfunction jcurl() {
curl -s "$@" | json | pygmentize -l json
}
function tojson(){| /** | |
| * Algirithm: reverse string using recursion. | |
| * Complexity: O(n) | |
| */ | |
| public class ReverseStringRecurse { | |
| public String reverse(String str) { | |
| if(str == null || str.length() < 2) | |
| return str; | |
| return reverse(str.substring(1)) + str.charAt(0); |
| /** | |
| * Returns persons via AJAX. | |
| * @return mixed JSON data | |
| */ | |
| public function actionFindAjax($q = null) { | |
| if(Yii::$app->request->isAjax && !empty($q)) { | |
| $out = ['results' => ['id' => '', 'text' => '']]; | |
| Yii::$app->response->format = Response::FORMAT_JSON; | |
| $query = new Query(); | |
| $result = $query->select([ |
| .wrap | |
| .container | |
| .col-md-9 | |
| .main-content | |
| p main content | |
| .col-md-3 | |
| .sidebar | |
| p sidebar |
touch ~/.zsh_functions
vim ~/.zsh_functionsfunction jcurl() {
curl -s "$@" | json | pygmentize -l json
}
function tojson(){| #! /usr/bin/python3 | |
| import sys | |
| from urllib.parse import unquote | |
| print(unquote(sys.argv[1])) |
| #! /usr/bin/python3 | |
| from urllib.parse import unquote | |
| print(quote(sys.argv[1])) |
| function getGetParameters() { | |
| var s1 = location.search.substring(1, location.search.length).split('&'), | |
| r = {}, s2, i; | |
| for (i = 0; i < s1.length; i += 1) { | |
| s2 = s1[i].split('='); | |
| r[decodeURIComponent(s2[0])] = decodeURIComponent(s2[1]); | |
| } | |
| return r; | |
| } | |
| window.ServerData = getGetParameters(); |
| # Taken from | |
| # @see https://www.daniweb.com/programming/software-development/code/216880/check-if-a-number-is-a-prime-number-python | |
| def is_prime(n): | |
| if n == 2 or n == 3: | |
| return True | |
| elif n < 2 or n % 2 == 0: | |
| return False | |
| elif n < 9: | |
| return True | |
| elif n % 3 == 0: |
| const PromisesBus = function() { | |
| this.promises = {}; | |
| this.resolves = {}; | |
| this.rejects = {}; | |
| } | |
| PromisesBus.prototype.when = function(what) { | |
| return this.register(what); | |
| }, | |
| PromisesBus.prototype.register = function(what) { | |
| if (this.promises.hasOwnProperty(what)) { |
| # Count is needed to limit amount of bytes read from /dev/urandom | |
| # fold controls letgth of displayed character sequences | |
| # head specifies number of passwords to generate | |
| # tr defines characters to use | |
| dd if=/dev/urandom bs=1 count=30000 status=none | tr -cd '[:graph:]' | fold -w 25 | head -n 40 |