Skip to content

Instantly share code, notes, and snippets.

View nisrulz's full-sized avatar
🌌
Coding in the MultiVerse

Nishant Srivastava nisrulz

🌌
Coding in the MultiVerse
View GitHub Profile
@nisrulz
nisrulz / DoubleBackPressExit.java
Created June 21, 2016 05:19
Get back press work only at second press and notify user to press again to exit.
private static long back_pressed;
@Override
public void onBackPressed(){
if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed();
else Toast.makeText(getBaseContext(), "Press once again to exit!", Toast.LENGTH_SHORT).show();
back_pressed = System.currentTimeMillis();
}
@nisrulz
nisrulz / ScanForWiFI.java
Created June 21, 2016 05:22
Scan for wireless network
public class WifiTester extends Activity {
TextView mainText;
WifiManager mainWifi;
WifiReceiver receiverWifi;
List<ScanResult> wifiList;
StringBuilder sb = new StringBuilder();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@nisrulz
nisrulz / README.md
Created July 4, 2016 17:08 — forked from JakeWharton/README.md
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!
@nisrulz
nisrulz / filter.regexp
Created July 10, 2016 10:16 — forked from stepango/filter.regexp
Filter for logcat
^(?!(NotificationManager|Timeline|SensorManager|Configs|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow))
@nisrulz
nisrulz / .gitconfig
Created July 13, 2016 06:18 — forked from donnfelker/.gitconfig
My .gitconfig
[user]
name = Your Name
email = you@youremail.com
[alias]
A = add -A
a = add
aa = add --all
ae = add --edit
ai = add --interactive
amend = commit --amend -C HEAD

Keybase proof

I hereby claim:

  • I am nisrulz on github.
  • I am nisrulz (https://keybase.io/nisrulz) on keybase.
  • I have a public key whose fingerprint is 664A 14E8 F9BA 8779 CF16 130D F526 A6BB E32F C33D

To claim this, I am signing this object:

@nisrulz
nisrulz / responsive.css
Created September 13, 2016 12:20
Media Queries for mobile
/* Media Queries */
/* ----------- iPhone 4 and 4S ----------- */
/* Portrait and Landscape */
@media only screen
and (min-device-width: 320px)
and (max-device-width: 480px)
and (-webkit-min-device-pixel-ratio: 2) {
@nisrulz
nisrulz / importcsvintomysql.py
Last active December 29, 2016 00:45
MySQL connection in python
import MySQLdb
import pandas as pd
from sqlalchemy import create_engine
# read the csv into pandas and then export to MySQL
template_lines = 1000
df = pd.read_csv(
'example.csv', nrows=template_lines, low_memory=False)
# 2nd argument replaces where conditions is False
df = df.where(pd.notnull(df), None)

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would