Skip to content

Instantly share code, notes, and snippets.

View firoze's full-sized avatar

Firoze Rakib firoze

  • Fieldwire
  • San Francisco
  • X @frzrkb
View GitHub Profile
Promise.resolve()
.then(() => Promise.resolve(">"))
.then(() => Promise.resolve(">>"))
.then(() => Promise.resolve(">>>"))
.then(() => Promise.resolve(">>>>"))
.then(() => Promise.resolve(">>>>>"))
.then(() => Promise.resolve(">>>>>>"))
.then(() => Promise.resolve(">>>>>>>"))
.then(() => Promise.resolve(">>>>>>>"))
.then(() => Promise.reject("get me out!"))
function runner(cb) {
if (Math.round(Math.random())) {
return void cb("error");
}
return void cb();
}
function callback(err) {
if (err) {
console.error(err);
@thefotes
thefotes / dupeImports.sh
Created June 28, 2015 19:11
Given a path to an Xcode project, loops through all files and checks to see if any files have been imported more than once in the same file.
#!/bin/bash
set -e
read -e -p "Enter path to Xcode project: " FILES
eval FILES=$FILES
find "$FILES" -type f \( -name "*.h" -or -name "*.m" \) | while read -r f;
do
/*
* Copyright (C) 2014 Chris Banes
*
* 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
@mxl
mxl / PageSplitter.java
Last active December 29, 2015 09:09
Class for splitting styled text to pages.
package com.codeoverdrive.util;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.style.StyleSpan;
import java.util.ArrayList;
import java.util.List;
@tikipatel
tikipatel / sierpinski_chaos.py
Created April 29, 2017 02:00
Generate Sierpinski Triangle with random numbers
'''
Chaos Game Sierpinski Triangle
Reference: https://www.youtube.com/watch?v=kbKtFN71Lfs
'''
import random
import matplotlib.pyplot as plt
from numpy.random import rand
def midPoint(p1, p2):
return ((p1[0] + p2[0]) / 2.0, (p1[1] + p2[1]) / 2.0)
@rafali
rafali / ResizeAnimation.java
Last active February 26, 2021 13:05
Resize animation on Android
public class ResizeAnimation extends Animation {
final int startWidth;
final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
this.targetWidth = targetWidth;
startWidth = view.getWidth();
}
@z8888q
z8888q / gist:7280681
Last active July 11, 2022 07:26
How to change an application icon programmatically in Android
//1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-//filter section
<activity android:name="ru.quickmessage.pa.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/CustomTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@devgeeks
devgeeks / s3-phonegap-upload.js
Created November 27, 2012 19:47
S3 direct upload
var options = new FileUploadOptions();
options.fileKey="fileupload";
var time = new Date().getTime();
var userId = getUserId(); // In my case, Parse.User.current().id;
var fileName = userId+"-"+time+".jpg";
options.fileName = fileName;
options.mimeType ="image/jpeg";
options.chunkedMode = false;
var uri = encodeURI("https://BUCKET_NAME.s3.amazonaws.com/");
@friggeri
friggeri / haiku
Created October 6, 2011 07:30
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",