Skip to content

Instantly share code, notes, and snippets.

@gilchris
gilchris / dkr
Last active February 14, 2024 05:45
docker command shortcut
#!/bin/bash
function fzf_container() {
docker container ls -a | fzf -m | awk '{print $1}'
}
function fzf_running_container() {
docker ps | fzf -m | awk '{print $1}'
}
function container() {
case $1 in
@gilchris
gilchris / extracting_script_in_html.js
Created January 8, 2021 18:55
Extracting script in HTML
function extractScript(str) {
let r = new RegExp(/<script[\s\S]*?>([\s\S]+?)<\/script>/mig);
return str.match(r)
.map(function (s) {
return s.replace(r, "$1");
});
};
@gilchris
gilchris / mktoday.sh
Created April 9, 2020 17:56
mkdir today
#!/bin/sh
mkdir $(date +'%Y%m%d')
@gilchris
gilchris / del_nohup.sh
Created December 17, 2018 09:15
Delete 'nohup.out' files In sub directories
rm -f $(find . 'nohup.out' | grep nohup.out)
@gilchris
gilchris / getQuery.js
Last active November 30, 2017 07:42
get parameter value from url
// https://stackoverflow.com/a/35430091/1615988
function getQuery(q) {
return (window.location.href.match(new RegExp('[?&]' + q + '=([^&]+)')) || [, null])[1];
}
@gilchris
gilchris / hosts_administrator.ps1
Created November 27, 2017 06:37
Execute notepad with hosts file as administrator
Start-Process -FilePath C:\Windows\notepad.exe -ArgumentList "C:\Windows\System32\drivers\etc\hosts" -Verb runAs
@gilchris
gilchris / pytest.bat
Created August 16, 2017 08:39
Pytest example for windows
@ECHO OFF
set PYTHONDONTWRITEBYTECODE=1
set PYTHONPATH=..\src
C:\Python35\Scripts\pytest.exe %*
@gilchris
gilchris / StopWatch.java
Created March 14, 2017 05:49
Simple running time checker
import android.util.Log;
public class StopWatch {
private static String TAG = "StopWatch";
private static long baseTime;
private static long lastCheckTime;
private static long nowTime;
@gilchris
gilchris / redmine_my_issue_highlighter.user.js
Last active November 6, 2017 09:03
Adding to highlighting login user name on redmine issue rows.
// ==UserScript==
// @name Redmine My Issue Highlighter
// @namespace https://gist.github.com/gilchris/71bb6c44625722e0ae0d31ea0378e788
// @include /^.*redmine.*$/i
// ==/UserScript==
(function() {
var activeUserLink = $("div[id='loggedas'] > a").attr('href');
$("a[href='" + activeUserLink + "']").each(function() { $(this).html("<b style='color:#000000'>" + $(this).html() + "</b>"); });
})();
@gilchris
gilchris / redmine_issue_time.js
Created March 10, 2017 01:27
Adding detail date and time info on Redmine issue page.
(function() {
if (location.href.indexOf('/issues/') > -1) {
$("a[title^='20']").each(function() { $(this).text($(this).text() + " (" + $(this).attr('title') + ")"); });
}
})();