Skip to content

Instantly share code, notes, and snippets.

@linusthe3rd
linusthe3rd / websocketPolling.js
Created March 2, 2014 17:40
WebSocket Reconnection with Basic Polling
// Polling example to reconnect a WebSocket connection. I recommend NOT using this in your app.
function createWebSocket () {
var connection = new WebSocket();
connection.onclose = function () {
setTimeout(function () {
// Connection has closed so try to reconnect every 10 seconds.
createWebSocket();
}, 10*1000);
@linusthe3rd
linusthe3rd / gist:9039696
Last active August 29, 2015 13:56
UIKit Corner Radius
#import "YourViewController.h"
#import <QuartzCore/QuartzCore.h> // required to modify the corner radius
//.....Setup your controller...
- (void)viewDidLoad {
[super viewDidLoad];
self.myView.layer.cornerRadius = 8; //add a corner radius to the UILabel
}
$(document).ready(function() {
var embedGist = function () {
$('a[href^="https://gist.github.com"]').each(function(i) {
if (writeCapture) {
var wrapper = $("<div></div>");
wrapper.insertAfter(this);
writeCapture.html(wrapper[0], '<script src="'+$(this).attr("href")+'.js"></script>');
$(this).remove();
} else {
#pragma unused(parameterName)
This file has been truncated, but you can view the full file.
{
"/src/js/bindingHandlers/include.js": {
"lineData": [
null,
4,
null,
null,
null,
4,
null,
@linusthe3rd
linusthe3rd / gist:4727217
Created February 7, 2013 00:21
in-place String reversal
void strrev(char *p) {
char *q = p;
while(q && *q) ++q; //get last char of the string
for(--q; p < q; ++p, --q) {
*p = *p ^ *q, //xor p
*q = *p ^ *q, // xor np w/ q to store p's value in q
*p = *p ^ *q; //xor np w/ nq to get q's original value in p
}
}
@linusthe3rd
linusthe3rd / Reverse.java
Last active December 12, 2015 05:59
reverse a string in java
class Reverse {
public static void main(String[] args) {
reverse("abcde");
}
public static void reverse(String str){
char[] str_arr = str.toCharArray();
int start = 0,
end = str_arr.length-1;
@linusthe3rd
linusthe3rd / iptables.rb
Created July 12, 2012 17:17
The commands needed to set an iptables configuration from an ERB template in Chef.
template "/etc/sysconfig/iptables" do
source "iptables.erb"
owner "root"
group "root"
mode "0600"
end
# Ensure that the iptables file adheres to the selinux requirements
execute "chcon" do
command "chcon system_u:object_r:system_conf_t:s0 /etc/sysconfig/iptables"
args = ['-f', 'my_build.xml', 'my_target1']
task :call_ant do
ant args
end
@linusthe3rd
linusthe3rd / gist:1214669
Created September 13, 2011 18:48
mygem gem spec
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'mygem/version'
Gem::Specification.new do |s|
s.name = "MyGem"
s.version = MyGem::VERSION
s.authors = ["strife25"]
s.email = [""]