Skip to content

Instantly share code, notes, and snippets.

View NekoTashi's full-sized avatar

Christopher Rubio Márquez NekoTashi

View GitHub Profile
@NekoTashi
NekoTashi / fb_login.js
Created October 19, 2016 14:55
Snippet de Ionic para hacer login con FB.
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
@NekoTashi
NekoTashi / threading_a_request_attack.py
Last active April 20, 2018 23:22
Ejemplo de sobrecarga de data por medio de requests.
"""
!python 3 required
- pip install requests
"""
import random
import requests
import string
from threading import Thread
@NekoTashi
NekoTashi / ejemplo.txt
Last active November 18, 2016 22:42
Tablero.
-,-,-,-,-,*,-
-,X,X,*,-,1,-
-,-,*,4,*,X,-
-,*,X,*,3,*,-
-,X,-,1,-,-,-
-,2,-,-,1,X,-
-,-,-,-,*,-,-
['Africa/Abidjan',
'Africa/Accra',
'Africa/Addis_Ababa',
'Africa/Algiers',
'Africa/Asmara',
'Africa/Asmera',
'Africa/Bamako',
'Africa/Bangui',
'Africa/Banjul',
'Africa/Bissau',
@NekoTashi
NekoTashi / tzdata.md
Created May 17, 2017 17:55
Configurando timezones en el servidor (Debian)

Actualizar tzdata

  • sudo apt-get update && sudo apt-get install tzdata

Setear timezone en el servidor

  • timedatectl status mostrará el setting actual.
  • timedatectl list-timezones muestra los timezones disponibles.
  • sudo timedatectl set-timezone America/Santiago lo setea.
@NekoTashi
NekoTashi / seed_pagination.py
Created November 9, 2017 19:41 — forked from bendavis78/seed_pagination.py
Example implementation of randomized pagination in django and django-rest-framework
"""
Adds a `seed` paramter to DRF's `next` and `prev` pagination urls
"""
from rest_framework import serializers
from rest_framework import pagination
from rest_framework.templatetags.rest_framework import replace_query_param
from . import utils
@NekoTashi
NekoTashi / leap_year.py
Created January 3, 2018 15:10
365 does not include leap year.
from datetime import datetime, timedelta
PYBITES_BORN = datetime(year=2016, month=12, day=19)
def my_gen_special_pybites_dates():
days = 1
while True:
dt = PYBITES_BORN + timedelta(days=days)
# if days % 100 == 0: # commented to print only 'every year'
@NekoTashi
NekoTashi / notas.md
Last active April 21, 2018 20:21
Proyecto Hugo Forms.

Notas

  • Mostrar el MS del server con 3 estados: rojo, amarillo, verde. Al presionar es elemento, que se muestre la explicación de cada uno de los colores.
  • Choice es un input que puede tener como dependecia otros inputs.

Convenciones

  • Form: Conjunto de inputs.
  • Input: Elemento que contiene un dato.
@NekoTashi
NekoTashi / activate_venv.sh
Created October 12, 2018 14:54
How to activate venv inside a bash script.
#!/bin/sh
set -e
cd "<virtualenv_dir>"
source bin/activate
# -- Your code here!
@NekoTashi
NekoTashi / notas.md
Created November 22, 2018 18:26
ArrayReferenceField
title Using Djongo Array Reference Field
permalink /using-django-with-mongodb-array-reference-field/

Array Reference field

The ArrayReferenceField is one of the most powerful features of Djongo. The ArrayModelField stores the embedded models within a MongoDB array as embedded documents for each entry. If entries contain duplicate embedded documents, using the ArrayModelField would require unnecessary disk space. The ManyToManyField on the other hand has a separate table for all the entries. In addition, it also creates an intermediate "through/join" table which records all the mappings.

The ArrayReferenceField is a bargain between the ArrayModelField and ManyToManyField. A separate collection is used for storing all entries (instead of embedding it as an array). This means there is no data duplication. However, the intermediate "through/join" mapping table is completely skipped! This is achieved by storing only a reference to the entries in the embedded array.