Skip to content

Instantly share code, notes, and snippets.

View jjdelc's full-sized avatar
🏠
Working from home

Jj jjdelc

🏠
Working from home
View GitHub Profile
@jjdelc
jjdelc / serve.py
Last active October 31, 2020 04:54
Direct upload/download between devices
#!/usr/bin/env python3
"""
Run this to serve a temporary upload/download page from your computer.
I use this to transfer files directly between my phone and any of my PCs. The
benefit over Dropbox or Syncthings is that this is direct and immediate.
No fuzz, no installation, no usernames. Just directly deposit the file. I
haven't tested this for very large files.
@jjdelc
jjdelc / crayola.json
Created February 20, 2012 06:32
Crayola colors in JSON format
[
{
"hex": "#EFDECD",
"name": "Almond",
"rgb": "(239, 222, 205)"
},
{
"hex": "#CD9575",
"name": "Antique Brass",
"rgb": "(205, 149, 117)"
@jjdelc
jjdelc / resizem.sh
Created May 22, 2011 21:54
Resize pictures in folder with ImageMagick
#!/bin/bash
#
# Resize all pictures in a folder
#
# This will modify the files, so MAKE A BACKUP before!
#
# usage:
# $> resizem.sh folder/name
#
@jjdelc
jjdelc / list_filter_collapse.js
Created May 22, 2011 08:56
Collapse list_filter in Django admin
;(function($){
ListFilterCollapsePrototype = {
bindToggle: function(){
var that = this;
this.$filterEl.click(function(){
that.$filterList.slideToggle();
});
},
init: function(filterEl) {
this.$filterEl = $(filterEl).css('cursor', 'pointer');
@jjdelc
jjdelc / gist:852323
Created March 3, 2011 04:16
Django RandomObjectManager
# -*- coding: utf-8 -*-
from random import sample
class RandomObjectManager(object):
"""
Manager Mixin to implement get_random() in your models.
You can override get_objects to tune the queriset
To use, define your class:
CmdUtils.CreateCommand({
names: ["Goo.gl", "shorten"],
description: "Shorten a URL using Google's shortener",
help: "Just use the url as the parameter",
author: {
name: "Jj",
email: "[email protected]",
homepage: "http://isgeek.net/",
},
license: "GPL",
diff -crB django_extensions/db/fields/__init__.py /home/jj/programas/django/extras/django-extensions/django_extensions/db/fields/__init__.py
*** django_extensions/db/fields/__init__.py 2010-07-05 16:15:30.000000000 -0500
--- /home/jj/programas/django/extras/django-extensions/django_extensions/db/fields/__init__.py 2010-07-05 16:23:38.000000000 -0500
***************
*** 67,91 ****
self._populate_from = (self._populate_from, )
slug_field = model_instance._meta.get_field(self.attname)
- slug_for_field = lambda field: self.slugify_func(getattr(model_instance, field))
if add or self.overwrite:
@jjdelc
jjdelc / x.js
Created October 6, 2009 01:59
Ubiquity ir.pe command
CmdUtils.CreateCommand({
names: ["irpe", "Irpe"],
icon: "http://ir.pe/favicon.ico",
description: "Replaces a url with a short ir.pe one.",
help: "irpe url",
author: {name: "Jesús Del Carpio", email: "[email protected]"},
license: "GPL",
homepage: "http://isgeek.net/",
arguments: [{role: 'object', nountype: noun_arb_text}],