Skip to content

Instantly share code, notes, and snippets.

View hidashun's full-sized avatar
🥶

Shunsuke Hida hidashun

🥶
View GitHub Profile
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@lambdamusic
lambdamusic / define.py
Last active February 15, 2023 14:52
Access osx dictionary in python
#!/usr/bin/env python
"""
# Version
2021-08-31
# Tested on
Python 3.9
@timonwong
timonwong / mysqldump.py
Created February 27, 2015 01:46
django mysqldump management command
# -*- coding: utf-8 -*-
import os
import sys
from optparse import make_option
from django.core.management.base import BaseCommand
from django.core.management.base import CommandError
from django.db import connections
from django.db import DEFAULT_DB_ALIAS
from django.db.backends import BaseDatabaseClient
@jexp
jexp / double_dir_shortest_path.adoc
Last active June 30, 2017 16:55
SO Question: Neo4j shortest path with rels in both directions

Neo4j shortest path with rels in both directions

I have a graph set up with the function…​

@voluntas
voluntas / django_trot.rst
Last active March 26, 2020 03:41
Django トラノマキ
@olooney
olooney / cropped_thumbnail.my
Created January 12, 2012 16:31
A "better" thumbnail algorithm for Python Image Library PIL Image
'''
PIL's Image.thumbnail() returns an image that fits inside of a given size (preserving aspect ratios)
but the size of the actual image will vary and is certainly not guaranteed to be the requested size.
This is often inconvenient since the size of the returned thumbnail cannot be predicted. The django-thumbs
library solves this for square thumbnails by cropping the image to a square and then resizing it. However,
this only works for exact squares.
This function generalizes that approach to work for thumbnails of any aspect ratio. The returned thumbnail
is always exactly the requested size, and edges (left/right or top/bottom) are cropped off to adjust to
make sure the thumbnail will be the right size without distorting the image.
@fauxparse
fauxparse / date.coffee
Created December 21, 2011 23:20
CoffeeScript date utilities
Number::pad = (digits, signed) ->
s = Math.abs(@).toString()
s = "0" + s while s.length < digits
(if @ < 0 then "-" else (if signed then "+" else "")) + s
Date.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
Date.weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
Date.formats =
"a": -> Date.weekdays[@getDay()].substring(0, 3)