Skip to content

Instantly share code, notes, and snippets.

@krallin
krallin / can-it-fork.c
Last active Jun 12, 2016
Can it fork?
View can-it-fork.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#define PRINT_ERROR(...) fprintf(stdout, "[ERROR (%i)] ", getpid()); fprintf(stdout, __VA_ARGS__); fprintf(stdout, "\n");
View gist:7cbd0f431d7be5ff3d40
### Keybase proof
I hereby claim:
* I am krallin on github.
* I am torozco (https://keybase.io/torozco) on keybase.
* I have a public key whose fingerprint is 6380 DC42 8747 F6C3 93FE ACA5 9A84 159D 7001 A4E5
To claim this, I am signing this object:
View gist:9e69f9c6d58d995b66bc
#!/bin/bash -e
####
# based on https://gist.github.com/jeffery/1115504
# Helper script to update the Last modified timestamp of files in a Git SCM
# Projects working Copy
#
# When you clone a Git repository, it sets the timestamp of all the files to the
# time when you cloned the repository.
#
# This becomes a problem when you want the cloned repository, which is part of a
@krallin
krallin / resolve.sh
Created Sep 24, 2014
Scalr Provided Script -- Resolve CVE-2014-6271 on managed instances
View resolve.sh
#!/bin/bash
has_yum=$(which yum)
has_apt=$(which apt-get)
function is_vulnerable {
env x='() { :;}; echo vulnerable' bash -c "echo this is a test" | grep "vulnerable"
return $?
}
View gist:4137f6b06dcc47ab3340
import boto.ec2
# Connect to EC2
conn = boto.ec2.connect_to_region("us-east-1") # Credentials are in the environment!
# Create a new SG
security_group = conn.create_security_group("test-sg, "Just making a point!")
# Define SG rules
ip_rules = [("tcp", 80, "0.0.0.0/0"), ("tcp", 443, "0.0.0.0/0")]
View gist:7849193
def expire_view_cache(view_name, args=None, kwargs=None, namespace=None, key_prefix=None, method="GET"):
"""
This function allows you to invalidate any view-level cache.
view_name: view function you wish to invalidate or it's named url pattern
args: any arguments passed to the view function
namepace: optioal, if an application namespace is needed
key prefix: for the @cache_page decorator for the function (if any)
from: http://stackoverflow.com/questions/2268417/expire-a-view-cache-in-django
added: method to request to get the key generating properly