Skip to content

Instantly share code, notes, and snippets.

View fjorgemota's full-sized avatar
🎯
Focusing

Fernando Jorge Mota fjorgemota

🎯
Focusing
View GitHub Profile
@fjorgemota
fjorgemota / sift3.py
Created July 7, 2012 19:41
Sift3 in Python
def sift3(s1,s2, maxOffset):
s1L = len(s1)
s2L = len(s2)
if not s1:
return (not s2 and 0 or s2L)
if not s2:
return s1L
c1 = 0
c2 = 0
lcs = 0
@fjorgemota
fjorgemota / functions.php
Created August 31, 2012 01:32 — forked from claudiosanches/functions.php
WP Is Current User
<?php
/**
* Verifica o papel do usuário.
*
* Exempo de uso:
* if (is_current_user('administrator')) {
* echo 'Olá administrador';
* }
*
* @param string $user
@fjorgemota
fjorgemota / convertHTMLtoJS.php
Created September 16, 2012 15:31
Convert HTML to Javascript using DOM in PHP
<?php
function convertHTMLtoJS($html){
if(is_string($html)){
$type = "string";
}
else{
$type = get_class($html);
}
switch($type){
case "DOMDocument":
@fjorgemota
fjorgemota / PrivateAttributes.py
Last active December 11, 2015 13:48
Simple example of a pratical method to create private attributes in Python using functions closures
class People:
'''Just a class to save the name of a people'''
def __init__(self, name):
'''Just saves the name of a people'''
obj = {} #A internal variable to save the state of the attribute
def setName(new_name):
'''Just a function to set the name of a people'''
obj["name"] = new_name #It's available in the internal variable representation
self.setName = setName #Just point it to the object
def getName():
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAkABzADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDh/svt+n/2NH2X2/T/AOxrd+zn0H5D/Gj7OfQfkP8AGv8AFc/DzC+y+36f/Y0fZfb9P/sa3fs59B+Q/wAaPs59B+Q/xoAwvsvt+n/2NH2X2/T/AOxrd+zn0H5D/Gj7OfQfkP8AGgDC+y+36f8A2NH2X2/T/wCxrd+zn0H5D/Gj7
@fjorgemota
fjorgemota / README.md
Created March 25, 2020 20:36
Small script to convert to x264, which is accepted by telegram, whatsapp and a lot of other services

Usage:

prepare-video source.mp4 output.mp4

The final video will use the x264 codec for video and aac codec for audio.

You'll need to install ffmpeg to be able to run that command.