Skip to content

Instantly share code, notes, and snippets.

View afr-dt's full-sized avatar
:octocat:

Alejandro Flores afr-dt

:octocat:
View GitHub Profile
@afr-dt
afr-dt / removeCommas.js
Created April 23, 2018 22:15
Remove commas with js from strings
str = '1,737,761.64'
str.replace(/,\s?/g, "")
OR
str.split(",").join("")
@afr-dt
afr-dt / gist:257066c5fcb2a91b5490281f197a8c96
Created April 27, 2018 16:52 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@afr-dt
afr-dt / database.yml
Created May 2, 2018 07:42
Config database.yml from Rails 5 with Postgres for development
# PostgreSQL. Versions 9.1 and up are supported.
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
host: localhost
database: development
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
@afr-dt
afr-dt / dateES6.js
Last active June 20, 2021 21:25
Date format ES6
let date = new Date('2018-06-20T15:03:22.297024');
let options = {
weekday: 'short',
year: 'numeric',
month: 'short',
day: 'numeric'
};
console.log(
date.toLocaleDateString('es-MX', options),
@afr-dt
afr-dt / settings.json
Last active March 22, 2019 21:58
My settings for vscode
{
"workbench.iconTheme": "vscode-icons",
"workbench.editor.enablePreview": true,
"html.autoClosingTags": true,
"html.format.preserveNewLines": true,
"editor.tabSize": 2,
"editor.snippetSuggestions": "top",
"workbench.colorCustomizations": {
"editor.fontLigatures": true,
"editor.selectionHighlight": true,
@afr-dt
afr-dt / pokemon.json
Created August 13, 2018 01:34 — forked from shri/pokemon.json
JSON of pokemon to go with my pokemonMoves.json file
{
"1":{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",
@afr-dt
afr-dt / import_csv_to_mongo
Created September 11, 2018 06:29 — forked from mprajwala/import_csv_to_mongo
Store CSV data into mongodb using python pandas
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
@afr-dt
afr-dt / description.md
Created September 28, 2018 18:57 — forked from mangecoeur/description.md
Pandas PostgresSQL support for loading to DB using fast COPY FROM method

This small subclass of the Pandas sqlalchemy-based SQL support for reading/storing tables uses the Postgres-specific "COPY FROM" method to insert large amounts of data to the database. It is much faster that using INSERT. To acheive this, the table is created in the normal way using sqlalchemy but no data is inserted. Instead the data is saved to a temporary CSV file (using Pandas' mature CSV support) then read back to Postgres using Psychopg2 support for COPY FROM STDIN.

@afr-dt
afr-dt / strip_srt.py
Created October 31, 2018 22:56
Strip punctuation from a string in Python
In [1]: import re
In [2]: tacos = "Tacos al pastor, suadero, bistec y de canasta."
In [3]: tacos = re.sub(r'[^a-zA-Z0-9\s]', '', tacos)
In [4]: tacos
Out[4]: 'Tacos al pastor suadero bistec y de canasta'

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by