Skip to content

Instantly share code, notes, and snippets.

View anuj-rajput's full-sized avatar
👨‍💻
NSNerd

Anuj Rajput anuj-rajput

👨‍💻
NSNerd
View GitHub Profile
@anuj-rajput
anuj-rajput / README.md
Last active June 1, 2017 16:41
Vaccination Problem

The World Health Organization (WHO) wants to establish a total of B vaccination clinics across N cities to immunize people against fatal diseases. Every city must have at least 1 clinic, and a clinic can only vaccinate people in the same city where they live. The goal is to minimize the number of vaccination kits needed in the largest clinic.

For example, suppose you have:

  1. 2 cities and
  2. 7 clinics to be opened.
  3. If 200,000 is the population of the first city and
  4. 500,000 is the population of the second city, then
  5. two clinics can open in the first city and
  6. five in the second. This way,
  7. 100,000 people can be immunized in each of the two clinics in the first city, and
@anuj-rajput
anuj-rajput / ShareImage.m
Created December 23, 2016 07:23
UIActivityViewController snippet
- (void)shareImage:(UIImage *)image {
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
}
@anuj-rajput
anuj-rajput / README.md
Last active August 8, 2016 14:18 — forked from bloudermilk/README.md
Facebook Page Categories

All of the categories!

I wrote a really simple JavaScript script that uses jQuery to extract all the categories from Facebook's "Create a page" page.

Instructions

  1. Navigate to the Create a page page.
  2. Open up your JavaScript console of choice and run the following script:
@anuj-rajput
anuj-rajput / AttributedPlaceholder.m
Last active August 29, 2015 14:24
Attributed Placeholder (Zendesk like.. NOT! Teamie Like)
// Attributed Placeholder Text
NSDictionary *subdomainAttributes = @{
NSFontAttributeName : [UIFont regularFontWithDefaultSize],
NSForegroundColorAttributeName : [UIColor grayColor]
};
NSDictionary *theteamieAttributes = @{
NSFontAttributeName : [UIFont regularFontWithDefaultSize],
NSForegroundColorAttributeName : [UIColor blackColor]
};
@anuj-rajput
anuj-rajput / git_stats.sh
Created May 13, 2015 07:23
Consolidates the git commit info and lists the usage for each author
#!/bin/bash
if [[ $1 == "" && $2 == "" ]]
then
echo "USAGE: $0 SINCE_DATE [AUTHOR_PATTERN]"
exit
fi
DATE=$1 # 10-1-2011, 2012-04-22, etc
AUTHOR=$2 # author pattern (regexp)
@anuj-rajput
anuj-rajput / .htaccess
Last active August 29, 2015 14:15
CodeIgniter .htaccess Rewrite URL Config
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@anuj-rajput
anuj-rajput / popup.html
Created March 20, 2012 23:01
JavaScript: Flickr GET
<link rel="stylesheet" href="/css/style.css">
<script>
var req = new XMLHttpRequest();
req.open(
"GET",
"http://api.flickr.com/services/rest/?" +
"method=flickr.photos.search&" +
"api_key=90485e931f687a9b9c2a66bf58a3861a&" +
"text=hello%20world&" +