Skip to content

Instantly share code, notes, and snippets.

View ikks's full-sized avatar

Igor Támara ikks

View GitHub Profile
@raveenb
raveenb / ssh_into_android.md
Last active April 18, 2024 06:27
SSH into Android

Connecting to an Android device over SSH

Initial Setup

Install Android App Termux from APKPure or AppStore. If the app exists, just delete and re-install it to get the latest version, The APK can be downloaded from https://apkpure.com/termux/com.termux/ Install the APK using by running

adb install ~/Downloads/Termux_v0.73_apkpure.com.apk
@john-guerra
john-guerra / README.md
Last active January 28, 2024 19:19 — forked from kristw/index.html
GeoJson map of Colombia

Geo Json map of Colombia

Based on the Map of Thailand by Master Krist Wongsuphasawat, a simple map of Colombia using GeoJSON and D3.js

As in Krist example:

  • Each province is color-coded by the length of its name in English.
  • Hover each province to see text effects.
  • New font is chosen randomly every time you change the province.
@cansadadeserfeliz
cansadadeserfeliz / plates.py
Created June 19, 2014 22:06
RegExp: Placas de carros colombianos. Colombian car plates validator.
from django.core.validators import RegexValidator
plates_validator = RegexValidator(
r'^([A-Z]{3}\d{3}|[A-Z]{2}\d{4}|[A-Z]{2}\d{3}[A-Z]|[A-Z]\d{4,5}|[A-Z]{3}\d{2}[A-Z])$',
u'Combinaciones posibles: ABC123, AB1234, AB123C, A1234, A12345, ABC12D'
)
# http://www.regexr.com/391ai
@cansadadeserfeliz
cansadadeserfeliz / views.py
Last active April 13, 2020 11:00
Django: filter DatetimeField by today (max and min time)
# source: http://stackoverflow.com/questions/1317714/how-can-i-filter-a-date-of-a-datetimefield-in-django
from django.utils import timezone
today_min = datetime.datetime.combine(timezone.now().date(), datetime.time.min)
today_max = datetime.datetime.combine(timezone.now().date(), datetime.time.max)
MyModel.objects.get(date__range=(today_min, today_max))
@cansadadeserfeliz
cansadadeserfeliz / admin.py
Last active May 13, 2020 14:00
Django: how to remove delete action/button from admin
class MyAdmin(admin.ModelAdmin):
def has_delete_permission(self, request, obj=None):
return False
def get_actions(self, request):
actions = super(MyAdmin, self).get_actions(request)
if 'delete_selected' in actions:
del actions['delete_selected']
return actions
@cansadadeserfeliz
cansadadeserfeliz / tests.py
Last active August 29, 2015 14:01
Django: ajax json view in tests
import json
from django.test import TestCase
class JSONViewTestCase(TestCase):
def test_json_view(self):
response = self.client.post(
reverse('my_json_view'),
json.dumps({
# your JSON
@lonetwin
lonetwin / print_table.py
Last active May 7, 2021 15:42
print out ascii tables in python using data in the form: [ ('column 0 title', 'column 1 title' ..), ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
# I needed to print out ascii tables from data in the form:
# [ ('column 0 title', 'column 1 title' ..),
# ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
#
# and surprisingly it got complicated because of variable lengths of the data.
# I googled for 'standard' ways of doing this and I found suggestions like:
# http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables
# ...which were a bit dated and hard to read or full scale modules like:
#
# http://pypi.python.org/pypi/texttable/
@ctavan
ctavan / gist:4482825
Last active February 18, 2019 16:09
Init-script for optionally starting multiple redis instances on the same host running Ubunut/Debian. Highly inspired by the memcached init script that comes with the Ubuntu package. This is useful since redis is single-threaded.
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@springmeyer
springmeyer / osm.pbf to postgis
Created November 1, 2010 07:23
import a pbf file into postgis from geofabrik using osmosis and osm2pgsql
# note: there is work afoot to load pbf directly with osm2pgsql
# http://lists.openstreetmap.org/pipermail/dev/2010-October/020953.html
# but for now osmosis >= 0.37 works best
# install java/osmosis if you don't already have it
sudo apt-get install sun-java6-jre
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-0.37.zip
unzip osmosis-0.37.zip
cd osmosis-0.37
chmod +x bin/osmosis