Skip to content

Instantly share code, notes, and snippets.

View chirag64's full-sized avatar

Chirag Bhatia chirag64

View GitHub Profile
@chirag64
chirag64 / scanner.sh
Created April 27, 2021 16:08 — forked from andyrbell/scanner.sh
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@chirag64
chirag64 / pandas_cheat.py
Created December 4, 2020 12:46 — forked from pohzipohzi/pandas_cheat.py
Cheat sheet for the python pandas library
import numpy as np
import pandas as pd
#### creating dataframes, adding and dropping columns
df = pd.DataFrame(np.arange(1,10).reshape(3,3),['A','B','C'],['w','x','y'])
df.columns = ['W','X','Y'] # change column names
df['Z']=df['X']+df['Y'] # new column with values X+Y
df['XX']=df.apply(lambda row: row['X']*2, axis=1) # new column with values twice of column X
df['YY']=1 # new column of ones
@chirag64
chirag64 / Mimic SQL select * statement in SOQL using Apex
Created April 21, 2018 19:27 — forked from johncasimiro/Mimic SQL select * statement in SOQL using Apex
A code snippet that mimics the popular Select * SQL syntax in force.com's Apex language.
/*
* @description: A code snippet that mimics the popular Select * SQL syntax in force.com's Apex language.
*/
// Initialize setup variables
String objectName = 'Contact'; // modify as needed
String query = 'SELECT';
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
// Grab the fields from the describe method and append them to the queryString one by one.
@chirag64
chirag64 / README.md
Created April 8, 2017 12:27 — forked from micjamking/README.md
[Git] Git-to-Github Workflow

Git Workflow

Below is our current practice for using Git (the technology) & Github (the repository) when collaborating on projects. This process assumes that you already have Git installed & configured, and there is an existing project repository on Github with a "development" branch already setup.

If you do not have Git installed, follow these instructions.

This process also assumes that you are using the command line, however most of these tasks can be performed with a desktop client like Github for Mac or Tower.

Process

Getting Started

1.) Open terminal and locate the project directory you wish to use.

@chirag64
chirag64 / GitHub-Forking.md
Created April 8, 2017 12:27 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

# Watch a file changes in the current directory,
# Execute all tests when a file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = Get-Location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($true)
# How to use:
#
# Dependencies - scort, imagemagick, i3lock
#
# Just place a lock.png in your home folder to overlay whatever you want
#!/bin/bash
scrot -e 'convert -blur 0x3 $f ~/lockbg.png'
convert -gravity center -composite ~/lockbg.png ~/lock.png ~/lockfinal.png
i3lock -i ~/lockfinal.png -p default -e
if (Object.defineProperty && Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(Element.prototype, "textContent") && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) {
(function() {
var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
Object.defineProperty(Element.prototype, "textContent",
{
get: function() {
return innerText.get.call(this);
},
set: function(s) {
return innerText.set.call(this, s);
@chirag64
chirag64 / uri.js
Last active August 29, 2015 14:05 — forked from jlong/uri.js
// var parser = document.createElement('a');
// parser.href = "http://user:secretpassword@example.com:3000/pathname/?search=test#hash";
// OR
var parser = new URL("http://user:secretpassword@example.com:3000/pathname/?search=test#hash");
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"