Skip to content

Instantly share code, notes, and snippets.

Avatar

Fran Urbano viraltux

View GitHub Profile
View .emacs
(setq user-emacs-directory (expand-file-name "~/Dropbox/.emacs.d/"))
(require 'org)
(org-babel-load-file (expand-file-name (concat user-emacs-directory "init.org")))
(load (locate-user-emacs-file "init.el"))
View init.org

Emacs

More interesting settings in http://mescal.imag.fr/membres/arnaud.legrand/misc/init.php and https://github.com/dz/dotfiles/tree/master/emacsd/configs Common problems with Emacs can be solve by removing the .elc (compiled files) and recompiling them with byte-recompile-directory. For just one file we can use byte-compile-file.

Check for more seetings in: http://www.i3s.unice.fr/~malapert/org/tips/emacs_orgmode.html

.emacs main content

a soft linked copy of the .emacs file should be place in the home directory ~ with cp -as ~/Dropbox/.emacs ~

The .emacs file will trigger the load and conversion of the init.org file and should contain the following lines in the begginning.

View init.el
;; https://stable.melpa.org/#/getting-started
(require 'package) ;; You might already have this line
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
@viraltux
viraltux / createt.R
Last active Aug 16, 2017
code to generate a CREATE table statement for POSTGRESQL useful to generate the CREATE TABLE scripts for existing CSV files and data.frames
View createt.R
createt <- function(table){
## code to generate a CREATE table statement for POSTGRESQL
## useful to generate the CREATE TABLE script for CSV files
## and data.frames
create.sql <- "SELECT
'CREATE TABLE ' || relname || E'\n(\n' ||
array_to_string(
array_agg(
' ' || column_name || ' ' || type || ' '|| not_null
)
View bayesian.p.value.R
#Combining P-Values via Naive Bayes
bpv <- function(pv){
#Bayesian Probability
bp <- function(p){
if (any(p>1/exp(1))) stop('All p-values musts be lower that 1/e')
1 / (1 + 1/(-exp(1)*p*log(p)))
}
#Naive Bayes
nb <- function(p){
@viraltux
viraltux / SubSV
Last active Sep 10, 2015
R function to that replaces 'key' tagged words (eg. $word) within a string with the value contained in the system by the local variable 'word'
View SubSV
SubSV <- function(string, env, key = '$'){
# Replaces 'key' tagged words (eg. $word) within a string with the value
# contained in the system by the local variable 'word'
#
# Args:
# string: string with 'key' tagged words.
# Returns:
# string with every 'key' tagged word replaced.
# Example:
# this <- 'by that'; SubSV('replace $this', environment())
@viraltux
viraltux / IChing
Last active Aug 31, 2016
R function returning six Yin Yang elements coded from 6 to 9 following the traditional method to obtain I Ching hexagrams as explained by Richard Whilhem book. http://aleadeum.com/2013/07/12/the-i-ching-random-numbers-and-why-you-are-doing-it-wrong
View IChing
IChing = function(N=6){
set = NULL
for(i in 1:N){
sign = 0
hand = 0
for(j in 1:3){
left = sample(1:(48-hand),1)
right = 49-hand-left
pinky = 1 ; right = right - 1
anular = ifelse(left%%4==0,4,left%%4);