Skip to content

Instantly share code, notes, and snippets.

View superkeyor's full-sized avatar

Keyor superkeyor

View GitHub Profile
@mahmoudimus
mahmoudimus / python-monkey-patch-built-ins.py
Created February 4, 2010 22:20
pythonic monkey patching built-in types
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@shreyansb
shreyansb / smtpexample.py
Created January 16, 2012 19:28
sample code to send a gmail using python
#!/usr/bin/python
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
gmail_user = "email@example.com"
@stevenworthington
stevenworthington / ipak.R
Created July 25, 2012 19:44
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@Moligaloo
Moligaloo / gist:3850710
Created October 8, 2012 04:22
Send mail with attachment and signature via AppleScript in OS X
tell application "Mail"
set theSubject to "Subject" -- the subject
set theContent to "Content" -- the content
set theAddress to "xxx@163.com" -- the receiver
set theSignatureName to "signature_name"-- the signature name
set theAttachmentFile to "Macintosh HD:Users:moligaloo:Downloads:attachment.pdf" -- the attachment path
set msg to make new outgoing message with properties {subject: theSubject, content: theContent, visible:true}
@radum
radum / DragHereToValidate.bat
Created November 14, 2012 08:01
SublimeText 2 IBM SPSS Dimensions (build system, syntax higlight, snippets, etc)
:: If you want to use a batch file try this. Make a shortcut and drag n drop the file to be validated on it
Call "mrScriptCL.exe" "{path_to_mrs_validator}\ProjectValidator.mrs" /a:mddpath=%1
PAUSE
@Tvangeste
Tvangeste / article-style.css
Last active October 31, 2022 04:25
My qt-style.css
#.dsl_headwords
#{
# white-space: nowrap;
#}
#.gddictname
#{
# width: 50%;
# white-space: nowrap;
# text-overflow: ellipsis;
# overflow: hidden;
@perrygeo
perrygeo / cca.r
Last active September 27, 2022 15:03
Canonical Correspondence Analysis in R using the vegan library
library(vegan)
library(labdsv)
data(varespec)
data(varechem)
vare.cca <- cca(varespec ~ Baresoil+Humdepth+pH+N+P+K+Ca+Mg+S+Al+Fe, data=varechem)
vare.cca
plot(vare.cca)
summary(vare.cca)
@IronistM
IronistM / save an R dataframe with the name specified by a string.r
Created November 29, 2013 13:13
save an R dataframe with the name specified by a string
# Create explicit data frames and TS objects given a list
market.list<- c("GR","CY","RU","RO","PL","UA","ROW")
for (i in market.list) {
tmp <- subset(data,Market==i)
tmp<-ts(tmp) # It's a timeseries afterall...
# Let's save the data somewhere so we don't get back all the time
filename <- paste("data_", i, sep="")
assign(filename, tmp)
save(filename, file=paste(filename, ".rda",sep=""))
}
@cmcculloh
cmcculloh / gst.sh
Last active November 8, 2017 06:34
Takes contents of clipboard, syntax highlights them, pasts them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
#!/bin/bash
# Takes contents of clipboard, syntax highlights them, places a copy in "gists" directory in Google Drive, pastes them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
# requires:
#* gist (https://github.com/defunkt/gist)
#* Google Drive
#* highlight (brew install highlight)
#* an alias that will run this file `alias gst="~/gst.sh"`