Skip to content

Instantly share code, notes, and snippets.

View 64lines's full-sized avatar

Julian Alexander Murillo 64lines

  • Huge Inc.
  • Medellin - Colombia
View GitHub Profile
###############################################
# Script settings and constants.
###############################################
SCRIPT_PATH = 'script.sql'
DB_CONNECTION = {
'db_host': 'myhost.redshift.amazonaws.com',
'db_name': 'somedb',
'db_username': 'user',
'db_password': 'pA$$word'
@64lines
64lines / caesar_encryption.js
Created October 9, 2018 16:28
[JAVASCRIPT] Caesar Encryption
var encrypt = function(plaintext, shiftAmount) {
var ciphertext = "";
for(var i = 0; i < plaintext.length; i++) {
var plainCharacter = plaintext.charCodeAt(i);
if(plainCharacter >= 97 && plainCharacter <= 122) {
ciphertext += String.fromCharCode((plainCharacter - 97 + shiftAmount) % 26 + 97);
} else if(plainCharacter >= 65 && plainCharacter <= 90) {
ciphertext += String.fromCharCode((plainCharacter - 65 + shiftAmount) % 26 + 65);
} else {
ciphertext += String.fromCharCode(plainCharacter);
@64lines
64lines / createDataFrame.py
Last active March 6, 2019 15:06
[PYSPARK] - Create dataframe from scratch
from pyspark.sql import SparkSession
spark = SparkSession.builder.master("local").appName("rel subject").getOrCreate()
columns = ['id', 'referringUrl']
vals = [
(1, 'http://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html'),
(2, 'https://stackoverflow.com/questions/33224740/best-way-to-get-the-max-value-in-a-spark-dataframe-column'),
(3, 'https://datascience.stackexchange.com/questions/11284/key-parameter-in-max-function-in-pyspark'),
]
@64lines
64lines / example_code.py
Created June 26, 2018 03:44
[PYSPARK] - Example Code
from pyspark.context import SparkContext
spark = SparkSession.builder.master("local").appName("rel subject").getOrCreate()
file_path = 'some_file.csv'
dataframe = spark.read.csv(path=file_path, header=True)
dataframe = dataframe.filter(dataframe['value'] >= 0.5)
@64lines
64lines / philosopher.py
Last active March 2, 2018 04:36
The Philosopher: A program that generates philosophic quotes...
##################################
# The Philosopher: A program that
# generates philosophic quotes...
#################################
import random
R = ["without", "under",
"between", "over", "on",
"after", "by", "because of", "next to", "on top",
"like", "through", "until", "from", "into", "to", "in",
@64lines
64lines / AUC.py
Created November 30, 2017 01:20
[PYTHON][SKLEARN] Area under the ROC curve evaluating model performance.
# Import necessary modules
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import cross_val_score
# Compute predicted probabilities: y_pred_prob
y_pred_prob = logreg.predict_proba(X_test)[:,1]
# Compute and print AUC score
print("AUC: {}".format(roc_auc_score(y_test, y_pred_prob)))
@64lines
64lines / Logistic Regression Plot.py
Created November 30, 2017 00:51
[PYTHON][SKLEARN] Plotting Logistic Regression Raw
# Import necessary modules
from sklearn.metrics import roc_curve
# Compute predicted probabilities: y_pred_prob
y_pred_prob = logreg.predict_proba(X_test)[:,1]
# Generate ROC curve values: fpr, tpr, thresholds
fpr, tpr, thresholds = roc_curve(y_test, y_pred_prob)
# Plot ROC curve
@64lines
64lines / Logistic Regression.py
Created November 30, 2017 00:45
[PYTHON][SKLEARN] Logistic Regression
# Import the necessary modules
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, classification_report
# Create training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42)
# Create the classifier: logreg
logreg = LogisticRegression()
@64lines
64lines / logisticalregression.py
Created November 19, 2017 17:50
[PYTHON][SKLEARN] Logistical Regression
# Import the necessary modules
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, classification_report
# Create training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42)
# Create the classifier: logreg
logreg = LogisticRegression()
@64lines
64lines / mongoose.js
Created November 18, 2017 16:28
[NODEJS][MONGOOSE] - Create Schema and Save data
var mongoose = require('mongoose');
var Schema = new mongoose.Schema({
filename: String,
path: String,
creationDate: Date
});
var Image = mongoose.model('Image', Schema);