Skip to content

Instantly share code, notes, and snippets.

View sheharyarn's full-sized avatar
🕶️
Working

Sheharyar Naseer sheharyarn

🕶️
Working
View GitHub Profile
@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;
@sheharyarn
sheharyarn / YoutubeDownloader.md
Last active October 15, 2022 06:26
Download Videos from Youtube in (Ruby || PHP)

Youtube Downloaders

Download Youtube Videos using Ruby or PHP

Just copy the appropriate script, provide the video_id and run. It will list download links for different qualities and streams.

:P

@sheharyarn
sheharyarn / keybase.md
Created January 7, 2015 22:52
My Verification on Keybase.io

Keybase proof

I hereby claim:

  • I am sheharyarn on github.
  • I am sheharyar (https://keybase.io/sheharyar) on keybase.
  • I have a public key whose fingerprint is 7D2B 59DB 7F60 9FD7 F4C4 E781 FA1F 9B9B 68FE B6FF

To claim this, I am signing this object:

@sheharyarn
sheharyarn / CardSwingAnimations.md
Last active March 16, 2021 08:04
Swing Animations for CardViews in Android

SwingUp Animations for Android

I use these snippets to implement Google Now Card appear-animations on Android. Add these two files to your res/anim/ folder and add a swing_anim_time integer to your values:

<!-- res/values/strings.xml -->
<integer name="swing_anim_time">750</integer>
@sheharyarn
sheharyarn / inline-asynctask.java
Last active March 30, 2020 10:01
Android in-line AsyncTask
// The Very Basic
new AsyncTask<Void, Void, Void>() {
protected void onPreExecute() {
// Pre Code
}
protected Void doInBackground(Void... unused) {
// Background Code
return null;
}
protected void onPostExecute(Void unused) {
@sheharyarn
sheharyarn / APIClient.java
Last active August 29, 2015 14:10
Using AndroidAsyncHttp Library
RequestParams params = new RequestParams();
params.put("email", "[email protected]");
params.put("password", "12345678");
APIClient.post("/login", params, new JsonHttpResponseHandler() {
// @Override them all
public void onStart() { } // Runs before anything else
public void onFinish() { } // Runs after everything else
@sheharyarn
sheharyarn / SQLiteHelper.java
Created November 12, 2014 22:25
Java: Create Tables in SQLite beautifully
public class SQLiteHelper extends SQLiteOpenHelper {
private static final String BOOK_TABLE = "books";
private static final HashMap<String, String> BOOK_FIELDS = new HashMap<String, String>() {{
put("title", "TEXT");
put("author", "TEXT");
put("sales", "INTEGER"); // Neatly write fields and their types
}};
// ...
@sheharyarn
sheharyarn / README.md
Last active August 29, 2015 14:05
Rails Server Shortcuts

Rails Server Shortcuts

Running this script will create three shortcuts (aliases) on your Server:

  • rc - Runs rails console in production
  • cdapp - CDs you into the current release of your app (capistrano)
  • applogs - Starts tailing the production.log of the current release of your app.

This script follows the ~/apps/appname/current directory structure.

@sheharyarn
sheharyarn / mongo_backup.sh
Last active December 12, 2024 15:16
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"