Skip to content

Instantly share code, notes, and snippets.

@sheeplogh
sheeplogh / gist:3421464
Created August 22, 2012 02:06
grep an accesslog(apache) file within a specific time period
$ cat ACCESS_LOG | awk '$4 >= "[29/Jan/2012:12:00:00" && $4 < "[29/Jan/2012:13:00:00"'
@alisdair
alisdair / kill-sticky.js
Created May 29, 2013 13:43
Kill sticky headers.
(function () {
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
if (getComputedStyle(elements[i]).position === 'fixed') {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@Juul
Juul / ssh-copy-id-openwrt
Last active August 23, 2023 11:10
ssh-copy-id but for openwrt / dropbear
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Example: ${0} [email protected]"
exit 1
fi
cat ~/.ssh/id_rsa.pub | ssh ${1} "cat >> /etc/dropbear/authorized_keys && chmod 0600 /etc/dropbear/authorized_keys && chmod 0700 /etc/dropbear"
@efrecon
efrecon / run.tpl
Last active November 12, 2024 10:10
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@yteraoka
yteraoka / kvm-host-dashboard.json
Created August 20, 2017 12:30
Grafana dashboard for KVM Host
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@KoffeinKaio
KoffeinKaio / sync_fb_dnsmasq.sh
Created November 28, 2018 20:09
sync fb host entrys to piholes list
#!/bin/bash
FB_IP=192.168.100.1
PIHOLE_LIST=/opt/pihole/etc/fb-sync.list
#0 if pihole is standalone, 1if its running in docker
DOCKER_ACTIVE=1
DOCKER_IP=192.168.100.10
DOCKER_PORT=2376
DOCKER_PIHOLE_NAME='pi-hole'
@magicdude4eva
magicdude4eva / zsh-syntax-highlighting paste performance improvement
Last active September 4, 2024 03:41
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
@movd
movd / watch_for_prometheus_changes.yaml
Created November 6, 2020 11:57
Hot reload Prometheus only on working config
#!/usr/bin/env bash
ls /etc/prometheus/*.yml \
| entr bash -c "promtool check config /etc/prometheus/prometheus.yml \
&& curl -X POST 'http://localhost:9090/-/reload'"