Skip to content

Instantly share code, notes, and snippets.

function rot13(encodedStr) {
var alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase().split("");
var codeArr = encodedStr.split("");
var decodedArr = [];
decodedArr = codeArr.map(function(a) {
if(alphabet.indexOf(a)!==-1) {
if(alphabet.indexOf(a)<13) {
return alphabet[26+alphabet.indexOf(a)-13];
} else {
return alphabet[alphabet.indexOf(a)-13];
import numpy as np
def cartesian(arrays, out=None):
"""
Generate a cartesian product of input arrays.
Parameters
----------
arrays : list of array-like
1-D arrays to form the cartesian product of.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@AbdouSeck
AbdouSeck / flask_unittesting.py
Last active July 10, 2018 22:38
Flask dummy app with unittest to provide a response to the stackoverflow question at https://stackoverflow.com/q/51252936/3135417
# application.py
from flask import Flask, render_template_string
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
"""
@AbdouSeck
AbdouSeck / group_until.R
Created October 3, 2018 00:03
R code to provide an answer to stackoverflow question at https://stackoverflow.com/q/52613778/3135417
# https://stackoverflow.com/q/52613778/3135417
# Function to keep track of diff changes along the V1 column
get_ids <- function(x) {
vrle <- rle(cummin(x))$lengths
rep(1:length(vrle), vrle)
}
# Thesis data
thesis <- data.frame(V1=c(8628, 8626, 8624, 8622, 8620, 8618,
# persons.txt
# Person 1
# Class Grade
# Math A
# Science C
# English A
# Person 2
# Class Grade
# Math D
# English A
#!/usr/bin/env python3
"""
Script to test or run commands on given servers.
./this_script.py test # To test all servers
./this_script.py run --id 127.0.0.1 --command "echo hello world"
"""
from argparse import ArgumentParser, RawDescriptionHelpFormatter as RDHF
def test_servers(servers):
# The arbitrary and opinionated conversion of strings to datetime in Series comparisons
# When comparing two values where the left side values is a pandas datetime object,
# Pandas casts the left side values to pd.DatetimeIndex
# Once the casting is successfully, Pandas then calls the __eq__ method on the result of the cast operation.
# In this case, you want to take a look at pd.DatetimeIndex.__eq__ to figure out how the comparison is being handled
# The following is how pd.DatetimeIndex.__eq__ is defined (it's a decorated function, so the function name doesn't come up):
def wrapper(self, other):

Keybase proof

I hereby claim:

  • I am abdouseck on github.
  • I am aseck (https://keybase.io/aseck) on keybase.
  • I have a public key ASDjVkM0h3zHkVUrkbaofaafZujw0FeGtxaYSAKgS4YnRQo

To claim this, I am signing this object:

@AbdouSeck
AbdouSeck / expand_ballrooms.R
Last active February 26, 2020 12:04
Reaction to the provided answer for Stackoverflow question at https://stackoverflow.com/q/35712196
# There is really not a dynamic way of doing what you want.
# You will need to expand the dash and generate a sequence from it.
# I wrote an example function that converts something like 2-4 into seq(2, 4)
expand.dash <- function(dashed) {
limits <- unlist(strsplit(dashed, '-'))
seq(limits[1], limits[2])
}
# We can use the above function inside another function which expands ballrooms