Skip to content

Instantly share code, notes, and snippets.

View sheharyarn's full-sized avatar
🕶️
Working

Sheharyar Naseer sheharyarn

🕶️
Working
View GitHub Profile
@squarism
squarism / iterm2.md
Last active April 25, 2024 03:50
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@zeroseis
zeroseis / disable-auto-android-file-transfer.md
Created September 14, 2015 17:28
Disable auto start for Android File Transfer
  • Close Android File Transfer
  • Open Activity Monitor and kill “Android File Transfer Agent”
  • Go to where you installed “Android File Transfer.app” (I have it under /Applications)
  • Ctrl+click –> “Show package contents”
  • Go to Contents/Resources
  • Rename “Android File Transfer Agent” to e.g. “Android File Transfer Agent_DISABLED”
  • Then go to “/Users/username/Library/Application Support/Google/Android File Transfer” and again rename the Agent app.
@mudphone
mudphone / CommonMacros.ex
Last active September 9, 2015 07:45
Pipe Right (Thread Right `->>` from Clojure) - Pipes left-hand expression into the left-most parameter or the next function call.
defmodule CommonMacros do
defmacro left ~>> right do
[{h, _}|t] = Macro.unpipe({:|>, [], [left, right]})
:lists.foldl fn
{{_, _, args} = x, _pos}, acc ->
pos = Enum.count(args)
Macro.pipe(acc, x, pos)
{x, pos}, acc ->
Macro.pipe(acc, x, pos)
@sheharyarn
sheharyarn / elixir_sips.exs
Last active December 22, 2021 08:42
Download videos from ElixirSips.com
defmodule Episode do
defstruct id: nil, name: nil, video: nil, markdown: nil, post: nil
def list do
[
%Episode{id: "001", post: "271", name: "Introduction and Installing Elixir", video: "1366", markdown: "1382" },
%Episode{id: "002", post: "275", name: "Basic Elixir", video: "1367", markdown: "1357" },
%Episode{id: "003", post: "280", name: "Pattern Matching", video: "14879", markdown: "1413" },
%Episode{id: "004", post: "284", name: "Functions", video: "5086", markdown: "1559" },
%Episode{id: "005", post: "298", name: "Mix and Modules", video: "5087", markdown: "1654" },
@henrik
henrik / chain.exs
Last active December 4, 2020 05:41
Silly #elixir-lang macro experiment for Ruby-like method chaining. Don't use this for serious purposes :)
defmodule Chain do
defmacro chain(ex) do
parse(ex)
end
defp parse({:., _, [first_arg, function_name]}, more_args) do
args = [first_arg|more_args] |> Enum.map(&parse/1)
apply(String, function_name, args)
end
@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@sheharyarn
sheharyarn / nginx.overrides
Created June 27, 2015 20:31
Restart / Reload Nginx without Entering Sudo Password
# Enter this command to create a sudoers override/include file:
# sudo visudo -f /etc/sudoers.d/nginx.overrides
# (Make sure you actually have this in your /etc/sudoers - Run `sudo visudo` to check)
# #includedir /etc/sudoers.d
# This file assumes your deployment user is `deploy`
# Nginx Commands
Cmnd_Alias NGINX_RESTART = /usr/sbin/service nginx restart
@iPaulPro
iPaulPro / include_list_viewpager.xml
Last active March 7, 2024 11:13
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
@sheharyarn
sheharyarn / mediastorm_caps.rb
Created March 15, 2015 11:05
Download Subtitles/Captions for MediaStorm Videos
#!/bin/env ruby
#### This Ruby Script extracts Captions as .srt files from
#### MediaStorm Videos (http://mediastorm.com)
#### Download The Video, and if you want to download captions,
#### lookup the 'Network' tab in Inspector to see the video id
#### It'll be a GET request to two xml documents on the mediastorm
#### server, namely; /timecodes/<id> and /phrases/<id>
@sheharyarn
sheharyarn / SimpleJSON.java
Last active March 13, 2019 17:44
Simple Java Class to convert Lists/Maps to JSON and vice versa
public class SimpleJSON {
/**
* @author: Sheharyar Naseer (@sheharyarn)
* @license: MIT
*/
public static Object toJSON(Object object) throws JSONException {
if (object instanceof HashMap) {
JSONObject json = new JSONObject();
HashMap map = (HashMap) object;