Skip to content

Instantly share code, notes, and snippets.

copy/delete word under cursor in Vim
yw / byw
Assuming that the cursor is at the first character of the word simply do this in command mode:
yw
y is for yank and w is for word.
Other ways of doing the same thing which are not as efficient:
vey
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.
@ackuser
ackuser / init.vim
Created March 28, 2022 07:33 — forked from celso/init.vim
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
@ackuser
ackuser / sketchapp_line_CSS
Created February 4, 2022 11:34 — forked from sktwentysix/sketchapp_line_CSS
Convert SketchApp line height to CSS
/*
Sketchapp fro MacOS is a fantastic tool for prototyping, but has some drawbacks that make converting designs to fully functional websites a pain.
One of these is sketchapp's line-height, which doesn't seem to have any relation to CSS line-height values.
This is a simple example of how we can take a line height value from sketch and apply it to a CSS class for styling text:
Lets assume the text in our Sketchapp prototype has a font size of "18px", and line height of "33"...
Our CSS class would look like this:
@ackuser
ackuser / dabblet.css
Created December 14, 2021 16:38 — forked from JosephSilber/dabblet.css
CSS Pac-Man
/* CSS Pac-Man */
#pacman {
width: 1px;
height: 1px;
border: 60px solid red;
border-right-color: transparent;
border-radius: 50%;
}
@ackuser
ackuser / mongodb-singleton.js
Created November 24, 2016 15:01 — forked from afshinm/mongodb-singleton.js
MongoDb singleton connection in NodeJs
var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
//the MongoDB connection
var connectionInstance;
module.exports = function(callback) {
//if already we have a connection, don't connect to database again
if (connectionInstance) {
callback(connectionInstance);
@ackuser
ackuser / git-pushing-multiple.rst
Created September 1, 2021 08:15 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@ackuser
ackuser / Validatedate.js
Created August 26, 2021 15:19 — forked from ace-racer/Validatedate.js
Validate date in JavaScript (dd/mm/yyyy format)
function validatedate() {
var dateText = document.getElementById("DATE_FIELD_NAME");
if (dateText) {
try {
var errorMessage = "";
var splitComponents = dateText.value.split('/');
if (splitComponents.length > 0) {
var day = parseInt(splitComponents[0]);
var month = parseInt(splitComponents[1]);
var year = parseInt(splitComponents[2]);
@ackuser
ackuser / forward.sh
Created March 4, 2021 20:23 — forked from aoxu/forward.sh
forward socks5 to http/https
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install privoxy
vim /usr/local/etc/privoxy/config
forward-socks5 / 127.0.0.1:1080 .
brew services start privoxy
export https_proxy=http://127.0.0.1:8118;export http_proxy=http://127.0.0.1:8118
@ackuser
ackuser / openconnect.md
Created February 19, 2021 07:13 — forked from moklett/openconnect.md
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@ackuser
ackuser / flushroute.sh
Created February 16, 2021 09:23 — forked from jckw/flushroute.sh
Fix for OpenVPN/ Tunnelblick: `Can't assign requested address`
# en1 for WLAN
# en0 for Ethernet
sudo ifconfig en1 down
sudo route flush
sudo ifconfig en1 up