Skip to content

Instantly share code, notes, and snippets.

@sj26
sj26 / phpserialize.py
Created February 2, 2010 09:53
Python port of PHP serialize() and unserialize()
#!/usr/bin/python -u
"""
Python port of PHP serialize() and unserialize()
by Samuel Cochran <sj26@sj26.com>
I couldn't find a nice, fairly efficient implementation of serialize/unserialize for Python... so I wrote one. I didn't use str().partition because I wanted Python <2.5 compatibility.
TODO: Performance review. There's an awful lot of string copying. >.>
@knoepfle
knoepfle / Google Insights.R
Created January 11, 2011 11:56
fetch a CSV file from a Google Insights search
#########################################
## GLOBAL REQUIREMENTS AND DEFINITIONS ##
#########################################
require(RCurl)
require(XML)
loginURL <- "https://accounts.google.com/ServiceLogin"
authenticateURL <- "https://accounts.google.com/accounts/ServiceLoginAuth"
insightsURL <- "http://www.google.com/insights/search/overviewReport"
@mtigas
mtigas / gist:952344
Last active June 20, 2024 11:22
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@CerebralMastication
CerebralMastication / ip2Int.R
Created June 22, 2011 16:23
convert IP address to integer
ip2Int <- function(ip){
split <- as.numeric(strsplit(ip, "\\.")[[1]])
out <- (split[1] * 256^3) + (split[2] * 256^2) + (split[3] * 256) + (split[4])
return(out)
}
int2Ip <- function(int){
split <- NULL
split[1] <- as.integer(int/256^3)
@meren
meren / qqplot.R
Created January 8, 2013 16:18
a substitute for qqplot and qqline.
#####################################################################################
# Q-Q plot in ggplot2
# taken from http://stackoverflow.com/questions/4357031/qqnorm-and-qqline-in-ggplot2
#####################################################################################
require(ggplot2)
vec <- Hg$AMT # whateer
y <- quantile(vec[!is.na(vec)], c(0.25, 0.75))
@nassimhaddad
nassimhaddad / non-ascii.R
Created January 26, 2013 18:13
remove non-ascii characters
# remove non-ascii characters
df$text <- gsub("[^\x20-\x7E]", "", df$text)
@wush978
wush978 / CMakeLists.txt
Created January 29, 2013 08:03
CMakeLists.txt for Rcpp Package Project
cmake_minimum_required(VERSION 2.8)
project(RcppPackage)
find_package(LibR)
if(${LIBR_FOUND})
else()
message(FATAL_ERROR "No R...")
endif()
message(STATUS ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "-e" "stopifnot(require('Rcpp'));cat(Rcpp:::Rcpp.system.file('include'))"
vif_func<-function(in_frame,thresh=10,trace=T,wts=NULL,...){
library(fmsb)
if(any(!'data.frame' %in% class(in_frame))) in_frame<-data.frame(in_frame)
if(is.null(wts))
wts <- rep(1, ncol(in_frame))
if(!is.null(wts))
if(length(wts)!=ncol(in_frame)) stop('length of weights must equal number of variables')
@SachaEpskamp
SachaEpskamp / global.R
Last active October 22, 2021 08:55
A general shiny app to import and export data to R. Note that this can be used as a starting point for any app that requires data to be loaded into Shiny.
library("shiny")
library("foreign")
@hubgit
hubgit / README.md
Last active June 14, 2024 17:40
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files