Skip to content

Instantly share code, notes, and snippets.

bf4648 / gist:24f4a14cf9f0c9447d1f8e12055ef57c
Created Jun 3, 2022 — forked from tyru/gist:984296
s:substring() and s:substring_once() in vital.vim
View gist:24f4a14cf9f0c9447d1f8e12055ef57c
" Substitute a:from => a:to by string.
" To substitute by pattern, use substitute() instead.
function! s:substring(str, from, to)
if a:str ==# '' || a:from ==# ''
return a:str
let str = a:str
let idx = stridx(str, a:from)
while idx !=# -1
bf4648 /
Created Sep 19, 2021 — forked from ralphcrisostomo/
Batch convert videos with HandBrake CLI
# Batch convert videos with HandBrake CLI
# By Ralph Crisostomo - 2016.04.17
# Usage :
# 'sudo ./ /source /destination'
# Reference :
bf4648 / .gdbinit
Created Aug 12, 2021 — forked from thobbs/.gdbinit
A version of .gdbinit that provides a pystack and pystackv command that does not hang forever. The problem appeared to be an infinite loop, so to fix it I just added a basic counter that breaks the while loop after 200 iterations.
View .gdbinit
# -*- ksh -*-
# If you use the GNU debugger gdb to debug the Python C runtime, you
# might find some of the following commands useful. Copy this to your
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
# start it up. Then, at the gdb prompt you can do things like:
# (gdb) pyo apyobjectptr
# <module 'foobar' (built-in)>
# refcounts: 1
bf4648 / vim find
Created Jun 26, 2021 — forked from jinzhubaofu/vim find
vim find from hades
View vim find
'Find' : 'find')<CR>
" Find file in current directory and edit it.
function! Find(name)
let l:list=system("find . -type f | grep -i '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
" let l:list=system("find . -iname '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
" replace above line with below one for gvim on windows
" let l:list=system("find . -name ".a:name." | perl -ne \"print qq{$.\\t$_}\"")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
bf4648 /
Created Jun 25, 2021 — forked from kennethreitz/
Various Python helper functions
# encoding: utf-8
""" Python General Helpers
Copyright (c) 2010 Kenneth Reitz. Creative Commons Attribution 3.0 License.
import urllib, re, time, sys
import paramiko
bf4648 / com.startup.plist
Created Jun 24, 2021 — forked from fahim0173/com.startup.plist
Launch Demon Start up with Bash Script with MySQL Example
View com.startup.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<!-- Launch Daemon do not always have access to all the path variables
As a results, scripts will sometimes fail if the you are using path variables inside them
To enable the script to have access to all path variables, open up a terminal and type in -->
<!-- echo $PATH -->
<!-- You can opt to filter out some of the path variables which are not required by script-->
bf4648 /
Created May 7, 2021 — forked from cmbaughman/
Searching for Text Books

Note: I found this on the /r/Piracy subreddit ( however I am including a copy here just in case.

So you have a list of books you need to buy for college. There are some really great resources for finding them online, but I'm going to run through the easiest methods for searching all of them here.

First, let's start off by using the method that will allow you to find the vast majority of books. Google. It tends to be easier if you can search multiple sites at once, and this is the easiest way to do it.

There was a search engine that /u/ratokursi made 3 years ago, but by now most of the sites are either dead or have changed the url. I decided to make a new one, this time after reviewing 100+ sites and adding to working ones to the custom search engine.

bf4648 /
Created Apr 26, 2021 — forked from wesleyit/
A default crontab header that will make the life easier for those who don't remember cron fields or keywords.
## Entry Description Equivalent To
## @yearly (or @annually) Run once a year at midnight in the morning of January 1 0 0 1 1 *
## @monthly Run once a month at midnight in the morning of the first of the month 0 0 1 * *
## @weekly Run once a week at midnight in the morning of Sunday 0 0 * * 0
## @daily Run once a day at midnight 0 0 * * *
## @hourly Run once an hour at the beginning of the hour 0 * * * *
## @reboot Run at startup @reboot
bf4648 /
Last active Apr 23, 2021 — forked from jfloff/
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

bf4648 / tmux.conf
Created Apr 20, 2021 — forked from markandrewj/tmux.conf
Basic Tmux Status Bar
View tmux.conf
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 5 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows