Skip to content

Instantly share code, notes, and snippets.

View citmusa's full-sized avatar

Citlalli Murillo citmusa

View GitHub Profile
@citmusa
citmusa / graphene.py
Created January 28, 2022 18:24 — forked from mixxorz/graphene.py
Get requested fields from ResolveInfo. Graphene python.
"""
MIT License
Copyright (c) 2018 Mitchel Cabuloy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@citmusa
citmusa / install.sh
Created May 19, 2017 15:56
mongodb in mac with homebrew
# install mongo
brew install mongodb
#create the path in which mongo will store databases (it is recommended not to change this path)
sudo mkdir -p /data/db
#give us permissions over data/db:
# get our name
whoami
# get ownership:
@citmusa
citmusa / upgrade.sh
Last active May 17, 2017 23:22
Update pip packages ov virtualenv
# All in environment
pip freeze --local | xargs -n1 pip install -U
#Also saving previous values
pip freeze --local | tee before_upgrade.txt | xargs -n1 pip install -U
#Just outdated
pip list --outdated --format=freeze --local | xargs -n1 pip install -U
@citmusa
citmusa / mac_defaults.sh
Created May 17, 2017 21:10
mac preferences
#!/usr/bin/env bash
# from — https://mths.be/macos
### General UI/UX ###
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
### Keyboard ###
@citmusa
citmusa / admin_template_tags.py
Created November 9, 2016 02:50
Django admin URL template tag
# Usage: <a href="{% admin_url model_instance %}">admin edit page</a>
from django.core import urlresolvers
from django.contrib.contenttypes.models import ContentType
from django import template
register = template.Library()
@register.simple_tag
def admin_url(instance):
@citmusa
citmusa / urls.py
Created November 9, 2016 02:28
Django simple logout and redirect.
url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
@citmusa
citmusa / email_amazonSES.py
Created October 27, 2016 17:09
send email with amazon SES service
# pip install boto3
import boto3
client = boto3.client('ses',
aws_access_key_id='XXXXXXXXXXXXXXXX',
aws_secret_access_key='XXXXXXXXXXXXXXXX',
region_name='us-east-1')
try:
response = client.send_email(Source='from@emaildomain.com',
Destination={'ToAddresses':['toemail@address.com']},
@citmusa
citmusa / conversion.js
Created October 13, 2016 20:35
time string (hh:mm:ss) to seconds and seconds to hh:mm:ss functions
String.prototype.toSeconds = function () {
if (!this) return null;
var hms = this.split(':');
return (+hms[0]) * 60 * 60 + (+hms[1]) * 60 + (+hms[2] || 0);
}
String.prototype.toHHMMSS = function () {
if (!this) return null;
var sec_num = parseInt(this, 10);
var hours = Math.floor(sec_num / 3600);
@citmusa
citmusa / dump_queryset.py
Last active November 9, 2016 02:30
Dump database to .json
import csv
from django.db.models.loading import get_model
def dump(qs, outfile_path):
"""
Takes in a Django queryset and spits out a CSV file.
Usage::
>> from utils import dump2csv
@citmusa
citmusa / example.html
Created December 4, 2015 17:09
Select with options sized (control of height)
<select name="select1" onmousedown="if(this.options.length>8){this.size=8;}" onchange='this.size=0;' onblur="this.size=0;">
<option value="1">This is select number 1</option>
<option value="2">This is select number 2</option>
<option value="3">This is select number 3</option>
<option value="4">This is select number 4</option>
<option value="large">This is select number asdf asf saf asdf sa12</option>
<option value="5">This is select number 5</option>
<option value="6">This is select number 6</option>
<option value="7">This is select number 7</option>
<option value="8">This is select number 8</option>