Skip to content

Instantly share code, notes, and snippets.

Adrián Navarro adrinavarro

Block or report user

Report or block adrinavarro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adrinavarro
adrinavarro / twitpic.js
Created Mar 31, 2017
Delete everything from Twitpic
View twitpic.js
javascript:(function()%7Bfunction%20delete_current()%20%7Bvar%20i%20%3D%200%3B%24(%22span.delete-image%22).each(function()%20%7Bi%2B%2B%3Bvar%20da%20%3D%20%24(this).attr(%22data-auth%22)%3Bvar%20id%20%3D%20%24(this).attr(%22data-id%22)%3BsetTimeout(()%20%3D%3E%20%7B%20%24.post(%22%2Fmedia%2Fdelete.json%22%2C%20%7Bauth_code%3A%20da%2C%20media_id%3A%20id%7D)%3B%20%7D%2C%20900*i)%3B%7D)%3B%7D%3Bfunction%20next_runs()%20%7BsetTimeout(()%20%3D%3E%20%7Bconsole.log(%22starting%20subsequent%22)%3B%24.get(%22%2Fphotos%2Fadrinavarro%22%2C%20%7B%7D%2C%20function(data)%20%7B%24(%22%23photo-container%22).html(%24(data).find(%22%23photo-container%22).html())%3Bdelete_current()%3B%7D)%3Bnext_runs()%3B%7D%2C%2022000)%3B%7D%3Bfunction%20main_run()%20%7Bconsole.log(%22starting%20main%22)%3Bdelete_current()%3Bnext_runs()%3B%7D%3Bmain_run()%7D)()
@adrinavarro
adrinavarro / default-hans
Created Aug 13, 2015
Hans init.d and default files for Debian
View default-hans
# filename: /etc/default/hans
# Default settings for hans. This file is sourced from
# /etc/init.d/hans
START_HANS="true"
HANS_ARGS="10.0.1.1 -r"
HANS_PASSWORD="h4x0r"
@adrinavarro
adrinavarro / gist:8226124
Created Jan 2, 2014
launchd plist for power_fixer (binchewer)
View gist:8226124
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.fixer.launched.power_fixer</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/sudo</string>
<string>/usr/bin/power_fixer</string>
@adrinavarro
adrinavarro / gist:6726189
Last active Dec 24, 2015
Requires BC. Convert info_hash from short versions (deprecated) to 40-char length ones.
View gist:6726189
<?php
function convert_base($numberInput, $fromBaseInput, $toBaseInput) {
if ($fromBaseInput == $toBaseInput) return $numberInput;
$fromBase = str_split($fromBaseInput,1);
$toBase = str_split($toBaseInput,1);
$number = str_split($numberInput,1);
$fromLen = strlen($fromBaseInput);
$toLen = strlen($toBaseInput);
$numberLen = strlen($numberInput);
View backup.sh
#!/bin/bash
BASE="/var/lib/vz/backup/dump"
DAY=`date +%Y_%m_%d`
CURRENT=`ls ${BASE}/vzdump-openvz-100-${DAY}-*.tar.lzo`
/bin/mv $CURRENT ${BASE}/current.tar.lzo
/bin/rm ${BASE}/vzdump-*
/usr/local/bin/s3cmd mv s3://bucket/prod.tar.lzo s3://bucket/prod-prev.tar.lzo
View TCPCliente.java
import java.io.*;
import java.net.*;
class TCPCliente {
public static void main(String args[]) throws Exception {
String frase = null;
String respuesta;
String server;
Integer port;
View gist:4114436
<?php
$crop = new Imagick($path);
$crop->setBackgroundColor("white");
$crop->flattenImages();
$crop->stripImage();
$crop->setImageFormat('jpeg');
$crop->setCompressionQuality(90);
// CropThumbnail genera una imagen de exactamente esas medidas (120x120) guardando proporción
View gist:4114395
<?php
/* File manipulation class */
class ProjectFiles {
function __construct($_parent) {
$this->_parent = $_parent;
}
function dir_contents($dir) {
$handler = opendir($dir);
View gist:4018243
import re, sys
if len(sys.argv) > 2:
inputname = sys.argv[1].strip()
outputname = sys.argv[2].strip()
input = open(inputname, 'r')
output = open(outputname, 'w')
line = True
View example.php
<?php
function send_mail($mail, $subject, $content) {
require_once '../libs/ses.php';
// AWS_KEY and AWS_SECRET_KEY are amazon key-pair settings (very easy to retrieve)
$ses = new AmazonSES(array('key' => AWS_KEY, 'secret' => AWS_SECRET_KEY));
return $ses->send_email('origin@domain.com', array('ToAddresses' => array($mail)), array('Subject.Data' => $subject, 'Body.Html.Data' => $content));
}
You can’t perform that action at this time.