Skip to content

Instantly share code, notes, and snippets.

View sunnypp's full-sized avatar

Sunny Pun sunnypp

View GitHub Profile
@niksmac
niksmac / zmv-examples.md
Created March 7, 2017 05:58
ZMV-Examples (require autoload zmv)

rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and

change the 1 to a 2 in the filename while preserving the rest of it.

$ zmv -n '(.)(<->)(.[^.]#)' '$1$(($2+1))$3' # would rename x.0001.y to x.2.y. $ zmv -n '(.0#)(<->)(.[^.]#)' '$1$(($2+1))$3'

Rename files to lower case

$ zmv '*' '${(L)f}'

serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..)

$ autoload zmv

@vasanthk
vasanthk / System Design.md
Last active May 3, 2024 16:37
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question: what is your most productive shortcut?

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

@Technowise
Technowise / validate_fb_auth_token.php
Created May 10, 2013 06:51
Validate Facebook Auth-Token. This helper function checks if the Facebook auth-token is valid, and belongs to the said facebook-id
<?php
// A helper function to validate Facebook Auth-Token.
// This checks if the Facebook auth-token is valid, and belongs to the said facebook-id
function is_facebook_auth_valid($facebook_token, $facebook_id)
{
$ch = curl_init();
$url="https://graph.facebook.com/me?access_token=".$facebook_token;
curl_setopt($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);