Skip to content

Instantly share code, notes, and snippets.

View rangav's full-sized avatar

Ranga Vadhineni rangav

View GitHub Profile
@rabinjoshi
rabinjoshi / RJViewController.m
Created December 9, 2012 20:37
Loading content in a WebView using NSURLConnection
@implementation RJViewController {
__weak IBOutlet UIWebView *_webView;
NSURLConnection *_urlConnection;
NSMutableData *_receivedData;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *urlString = @"http://google.com";
@mraaroncruz
mraaroncruz / hn.sql
Created April 2, 2013 08:29
Hacker News algorithm in SQL
SELECT x.*
FROM POSTS x
JOIN (SELECT p.postid,
SUM(v.vote) AS points
FROM POSTS p
JOIN VOTES v ON v.postid = p.postid
GROUP BY p.postid) y ON y.postid = x.postid
ORDER BY (y.points - 1)/POW((((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(x.timestamp))/3600)+2, 1.5) DESC
LIMIT n
@nicwise
nicwise / PDFUtils.cs
Created April 23, 2013 12:32
PDF download and viewing - Xamarin.iOS
using System;
using System.IO;
using System.Threading.Tasks;
using MonoTouch.UIKit;
using MonoTouch.QuickLook;
using System.Net;
using MonoTouch.Foundation;
using System.Security.Cryptography;
using System.Text;
@ThomasArdal
ThomasArdal / Customer.cs
Created June 12, 2014 18:33
Elasticsearch migration c# example
namespace ConsoleApplication1
{
public class Customer
{
public int Zipcode { get; set; }
}
}

Building our first Camera App

In the first ever SwiftCast TV screencast. We will teach you how to build a Camera application that allows you to take a photo, select an existing photo, and view our selected photo. Let’s get started.

Chapter 1: Setting up our Application

Create a new Application by clicking "Create a new Xcode project". When asked to Choose a template for your new project, we are going to select "Single View Application" under iOS/Application. Then click the "Next" button.

@johnbabb
johnbabb / http_performance_test_concurrent.cs
Last active May 20, 2022 23:54
C# http performance test
string baseUrl = "http://localhost";
void Main()
{
var urls = new string[] {
"/url/endpoint",
};
var concurrentRequests = new int[]{ 1, 5, 25, 50, 100, 500, 1000};
var numberOfTurns = 10;
RunTests(urls, concurrentRequests, numberOfTurns);
@vparihar01
vparihar01 / importVideoToAppDir.swift
Created June 26, 2015 14:17
Importing video using the AVAssetExportSession session
Hey Isarathg this is classic use case of IOS devices. Which don't let you access any Photo Album assets directly using path value. To cross check my answer please just check FileExistsAtPath for your file like below -:
println(NSFileManager.defaultManager().fileExistsAtPath( urlvalue.path!))
O/P you will get => False
I also end up with this issue couple of days back After reading the whole IOS documentation. What I have figured it out "We can only access PhotoAlbum Assets if and only if we have PHImageManager session open". To cross check this statement please try below code -:
var currentVideofetch: PHFetchResult!
required init(coder aDecoder: NSCoder) {
@sciolist
sciolist / CorsProxy.swift
Created July 8, 2015 08:07
GCDWebServer Cors proxy
import GCDWebServer
class CorsProxy {
init(webserver : GCDWebServer!, urlPrefix: String) {
var prefix =
(urlPrefix.hasPrefix("/") ? "" : "/")
+ urlPrefix
+ (urlPrefix.hasSuffix("/") ? "" : "/")
let pattern = "^" + NSRegularExpression.escapedPatternForString(prefix) + ".*"
@tahmidsadik
tahmidsadik / purgeAndroid.txt
Created September 19, 2015 18:47
How to completely remove Android Studio from Mac OS X
How to Completely Remove Android Studio
Execute these commands from the terminal
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
@woxtu
woxtu / LICENSE
Last active January 31, 2020 13:31
Time-lapse -ify in Swift
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE