Skip to content

Instantly share code, notes, and snippets.

View diogo-almeida's full-sized avatar

Diogo Almeida diogo-almeida

View GitHub Profile
@benmarwick
benmarwick / rotate-axis-labels-ggplot2.R
Last active March 30, 2024 08:00
I can never remember how to rotate the x-axis labels with ggplot2: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
library(ggplot2)
td <- expand.grid(
hjust=c(0, 0.5, 1),
vjust=c(0, 0.5, 1),
angle=c(0, 45, 90),
@kingjr
kingjr / ipyvolume_topo.ipynb
Created January 17, 2018 04:14
ipyvolume_topo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0x4D31
0x4D31 / beautiful_idiomatic_python.md
Last active April 19, 2024 09:17 — forked from JeffPaine/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@whophil
whophil / jupyter-style.ipynb
Last active November 27, 2021 09:40
Pretty style for Jupyter notebooks using Google web-fonts. Apply to all your notebooks using %run magic.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@unhammer
unhammer / mwdump-to-pandoc
Last active December 25, 2022 18:34
Turn wikipedia dumps into plaintext using pandoc
#!/bin/bash
declare OUTFORMAT=plain
set -e -u
run () {
local text=false
local -i i=0
local out
@rasmusab
rasmusab / tensorflow_in_r_using_rpython.R
Last active April 25, 2018 02:35
An example of building a TensorFlow model from R using rPython
### An example of building a TensorFlow model from R using rPython ###
# For this script you need to
# 1. Have python 2.7 installed.
# 2. Install the rPython package in R.
# 3. Install Google's TensorFlow library as per these instructions:
# http://www.tensorflow.org/get_started/os_setup.md#binary_installation
### Here is how to setup and run a trivial TensorFlow model ###
# Load TensorFlow (I couldn't get this to work without setting sys.argv... )
@MarkEdmondson1234
MarkEdmondson1234 / dygraph_plot.r
Last active May 31, 2017 08:53
An example of rendering a Dygraph plot in Shiny
## in server.r
output$null_plot <- renderDygraph({
## don't output anything unless you have the data ready
validate(
need(casualImpactData(), "Model Working")
)
## the data for the plot is in here
ci <- casualImpactData()$series
@robinvanemden
robinvanemden / QualtricsQuestionJs.js
Created November 3, 2014 18:07
Adding jsPsych to Qualtrics
Qualtrics.SurveyEngine.addOnload(function() {
//Retrieve the Response ID from the hidden Qualtrics Session ID value
var responseIdFromSessionID = jq('#SessionID').val().replace("SS_", "R_");
//Retrieve Qualtrics object and save in qthis
var qthis = this;
//Hide buttons - can also (even better) be hidden in the CSS
jq('#Buttons').css("display", "none");
@tomhopper
tomhopper / plot_aligned_series.R
Last active June 25, 2023 17:36
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
@alexpchin
alexpchin / Add_Existing_Project_To_Git.md
Created June 1, 2014 20:14
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init