Skip to content

Instantly share code, notes, and snippets.

@gengue
gengue / instagramPhotoDownloader.js
Last active September 18, 2017 13:23
How download all your photos from instagram
/*
* Download as plain file
* @param {String} filename
* @param {String} text data
*/
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
@gengue
gengue / index.html
Last active April 28, 2017 21:10
Facebook page autolike
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>AutoLike Test</title>
<style type="text/css" media="screen">
#iframe-wrapper {
overflow: hidden;
width: 10px;
@gengue
gengue / serializers.py
Last active February 2, 2023 03:50
Django Rest Framework user endpoint with change password
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from rest_framework import serializers
from .models import User
class UserSerializer(serializers.ModelSerializer):
"""
User accounts serializer
@gengue
gengue / ordering.py
Created March 16, 2017 23:28
Performance benchmark Bubble vs Quicksort
import random
import time
def quicksort(items):
lowest = []
equal = []
greater = []
if len(items) > 0:
@gengue
gengue / .babelrc
Created February 23, 2017 22:19 — forked from thejmazz/.babelrc
async/await with webpack+babel
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@gengue
gengue / base.by
Last active February 11, 2017 17:31
Unescape special chars in Django VersatileImage
#python3.5/versatileimagefield/datastructures/base.py
# -*- coding: utf-8 -*-
def retrieve_image(self, path_to_image):
"""Return a PIL Image instance stored at `path_to_image`."""
from urllib.parse import unquote
image = self.storage.open(unquote(path_to_image), 'rb')
file_ext = path_to_image.rsplit('.')[-1]
image_format, mime_type = get_image_metadata_from_file_ext(file_ext)
@gengue
gengue / rename.sh
Created November 15, 2016 22:35
Rename all files in a directory (BASH)
for file in *_p.png
do
mv "$file" "${file/_p.png/_prueba.png}"
done
@gengue
gengue / download.sh
Last active July 27, 2016 23:32
Download entire website
wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://site/path/
#
wget -r --no-parent http://www.mysite.com/Pictures/
@gengue
gengue / focus.directive.js
Last active September 12, 2017 20:28
Focus directive angularjs
angular.module('app.layouts').directive('focusMe',
function($timeout, $parse) {
return {
link: function(scope, element, attrs) {
var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
@gengue
gengue / lyric.sh
Last active July 16, 2016 01:13
Get song lyrics from terminal.
#!/bin/bash
if [ "$#" -eq 0 ]; then
artist_name=`osascript -e'tell application "iTunes"' -e'get artist of current track' -e'end tell'`
song_title=`osascript -e'tell application "iTunes"' -e'get name of current track' -e'end tell'`
else
artist_name=$1
song_title=$2
fi