This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Twitter Parsers | |
String.prototype.parseURL = function() { | |
return this.replace(/[A-Za-z]+://[A-Za-z0-9-_]+.[A-Za-z0-9-_:%&~?/.=]+/g, function(url) { | |
return url.link(url); | |
}); | |
}; | |
String.prototype.parseUsername = function() { | |
return this.replace(/[@]+[A-Za-z0-9-_]+/g, function(u) { | |
var username = u.replace("@","") | |
return u.link("https://twitter.com/"+username); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void btnCopyClicked(View view){ | |
LinearLayout container = (LinearLayout)view.findViewById(R.id.container_id); | |
TextView txt1 = (TextView)view.findViewById(R.id.txtView_id); | |
TextView txt2 = new TextView(this); //this = context | |
txt2.setText(txt1.getText()); | |
conatiner.addView(txt2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void postNewComment(Context context,final UserAccount userAccount,final String comment,final int blogId,final int postId){ | |
mPostCommentResponse.requestStarted(); | |
RequestQueue queue = Volley.newRequestQueue(context); | |
StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { | |
@Override | |
public void onResponse(String response) { | |
mPostCommentResponse.requestCompleted(); | |
} | |
}, new Response.ErrorListener() { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Example | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Copyright 11.11.13 Michell Gailing <gailing.michell@gmail.com> | |
#It's Licensed under DWWWI 'Do whatever you want with it!' | |
wget http://www.okean.com/chinacidr.txt | |
sed -i '1,4d' chinacidr.txt | |
sed -i 's/ China//g' chinacidr.txt | |
ipset create china hash:net | |
while read line; do ipset add china $line; done < chinacidr.txt | |
iptables -I INPUT -m set --match-set china src -j DROP | |
rm chinacidr.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Script to process ip ranges to ban using IPSet and IPTables | |
ipset create countryblock hash:net | |
while read line; do ipset add countryblock $line; done < blocklist.txt | |
iptables -I INPUT -m set --match-set countryblock src -j DROP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]]; | |
NSData *imageData = UIImageJPEGRepresentation(image, 1.0); | |
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; | |
[request setHTTPShouldHandleCookies:NO]; | |
[request setTimeoutInterval:60]; | |
[request setHTTPMethod:@"POST"]; | |
NSString *boundary = @"unique-consistent-string"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; | |
return YES; | |
} | |
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | |
{ | |
if ([[ItemManager new] reloadItemDataSynchronous]) { | |
ItemHelper *helper = [ItemHelper new]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.webServer> | |
<staticContent> | |
<remove fileExtension=".woff" /> | |
<mimeMap fileExtension=".woff" mimeType="application/font-woff" /> | |
</staticContent> | |
</system.webServer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<Comment> toThreadedComments(List<Comment> comments){ | |
//comments should be sorted by date first | |
//The resulting array of threaded comments | |
List<Comment> threaded = new ArrayList<Comment>(); | |
//An array used to hold processed comments which should be removed at the end of the cycle | |
List<Comment> removeComments = new ArrayList<Comment>(); |
OlderNewer