Skip to content

Instantly share code, notes, and snippets.

@krallin
krallin / can-it-fork.c
Last active June 12, 2016 11:32
Can it fork?
#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");
### 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:
enable_all false
#!/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 September 24, 2014 16:58
Scalr Provided Script -- Resolve CVE-2014-6271 on managed instances
#!/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 $?
}
@krallin
krallin / gist:4137f6b06dcc47ab3340
Last active August 29, 2015 14:04
AWS API Sample
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")]
@krallin
krallin / gist:7849193
Last active December 30, 2015 15:38 — forked from dpnova/gist:1223933
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