Skip to content

Instantly share code, notes, and snippets.

View ayushgoel's full-sized avatar

Ayush ayushgoel

View GitHub Profile
@ayushgoel
ayushgoel / HTTPResponse.m
Created April 29, 2018 07:09
Handling network responses
- (void)makeNetworkCall {
NSURL *URL = nil; // replace with own URL
[[NSURLSession sharedSession] dataTaskWithURL:URL
completionHandler:
^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != nil) {
NSLog(@"Got error for request with URL: %@", URL);
[self handleError:error];
return;
}
for i in `find . -name '*.m'`;
do
if [[ -f $i ]]; then
line_count=`wc -l "$i" | awk {'print $1'}`
if [[ $line_count -gt 1000 ]]; then
echo $line_count " " $i
fi
fi
done
// https://www.hackerrank.com/challenges/insertionsort1
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
void print_ar(int size, int *ar) {
for (int i = 0; i < size; ++i) {
//https://www.hackerrank.com/challenges/cipher
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
char xor(char a, char b) {
int ai = a-'0';
int bi = b-'0';
//https://www.hackerrank.com/challenges/coin-change
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int coins[55];
long sol[255];
int m;
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
long max(long a, long b) {
return (a > b) ? a : b;
}
long get_contiguous_solution(int n, int *a) {
# coding: utf-8
#!/usr/bin/env python
import urllib2, re, os
#from BeautifulSoup import BeautifulSoup
#import simplejson as json
import json
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
def fetchPage(url):
@ayushgoel
ayushgoel / asyncio_example.py
Last active September 3, 2015 07:33
Example using asyncio of Python 3
# def xx(num):
# n = 0
# while n < num:
# yield n
# print(n)
# n += 1
# x = xx(12)
# for i in x:
# print("asd", i)
#!/usr/bin/env python
import random
import itertools
def rindex(alist, value):
return len(alist) - alist[-1::-1].index(value) - 1
def getAvailability(arr, val):
return [i.count(val) > 0 for i in arr]