Skip to content

Instantly share code, notes, and snippets.

View davidglezz's full-sized avatar
😃
Happy

David Gonzalez davidglezz

😃
Happy
View GitHub Profile
@davidglezz
davidglezz / getMonthDays.js
Last active August 29, 2015 13:56
Gets the number of days in a month (0-11)
// without lookup table
function getMonthDays_A (month, year)
{
if (month === 1)
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
if (month % 2)
return month > 6 ? 31 : 30;
return month > 6 ? 30 : 31;
@davidglezz
davidglezz / TuentiPhotoUntag.js
Last active August 29, 2015 13:56
Tuenti Photo Untag Script :: Script que automatiza el proceso de desetiquetarse de fotos. ¿Como se usa? Abre el album de fotos en las que estas etiquetado, pulsa F12 dirígete a la pestaña consola, pega el script y pulsa "Enter".
var urlFotoAnterior = "";
var interval = setInterval(function() {
try {
var urlFotoActual = document.getElementById("photo_image").getAttribute("src");
if (urlFotoActual != urlFotoAnterior)
{
urlFotoAnterior = urlFotoActual;
document.querySelector("#edit_tag_list .js-deleteTag .avatar").click();
@davidglezz
davidglezz / TuentiPhotoRemove.js
Last active August 29, 2015 13:56
Tuenti Photo Delete Script :: Script que automatiza el proceso de eliminación de fotos. ¿Como se usa? Abre el album de fotos que subiste, pulsa F12 dirígete a la pestaña consola, pega el script y pulsa "Enter".
var urlFotoAnterior = "";
var interval = setInterval(function (){
try {
var urlFotoActual = document.getElementById("photo_image").getAttribute("src");
if (urlFotoActual != urlFotoAnterior)
{
urlFotoAnterior = urlFotoActual;
document.getElementById("photo-actions-remove").click();
@davidglezz
davidglezz / generateFiles.sh
Created February 11, 2014 09:04
Little script to generate 1000 folders, with 100 files each of 100kbyte.
for i in `seq 1 1000`; do
mkdir -p files-$i;
for j in `seq 1 100`; do
dd if=/dev/zero of=files-$i/$j bs=100k count=1 2> /dev/null;
done;
done
@davidglezz
davidglezz / FastFtol.cpp
Created June 12, 2014 19:14
Fast Float to Int conversion
inline int FastFtol(const float a)
{
static int b;
#if defined(_MSVC)
__asm fld a
__asm fistp b
#elif defined(__GNUG__)
// use AT&T inline assembly style, document that
@davidglezz
davidglezz / id3v1_genres.sql
Created November 3, 2013 17:52
id3v1 genres
INSERT INTO `music`.`genre`
VALUES (0, 'Blues'),
(1, 'Classic Rock'),
(2, 'Country'),
(3, 'Dance'),
(4, 'Disco'),
(5, 'Funk'),
(6, 'Grunge'),
(7, 'Hip-Hop'),
(8, 'Jazz'),
@davidglezz
davidglezz / StrTrimLeft.c
Created November 4, 2013 16:12
This function remove whitespaces from the beginning.
void StrTrimLeft(char *source, char *dest)
{
int nIndex = 0;
while (source[nIndex] == ' ')
nIndex++;
strcpy(dest, &source[nIndex]);
}
@davidglezz
davidglezz / removeQuotes.c
Last active December 27, 2015 09:39
Remove quotes from command line arguments
void removeQuotes(LPSTR szCommand)
{
int nGet = 0, nSet = 0;
while (szCommand[nGet] != '\0')
{
if (szCommand[nGet] == '\"')
nGet++;
else
{
@davidglezz
davidglezz / GetColorsBits.c
Created November 4, 2013 16:17
Get the number of color bits in the current screen device.
int GetColorsBits()
{
HDC hScreenDC = GetDC(0);
int nColorBits = GetDeviceCaps(hScreenDC, BITSPIXEL) * GetDeviceCaps(hScreenDC, PLANES);
ReleaseDC(NULL, hScreenDC);
return nColorBits;
}
@davidglezz
davidglezz / OpenFileDialog.c
Last active December 27, 2015 09:39
Display 'Open File' dialog-box in Windows
//Display 'Open File' dialog-box
BOOL OpenFileDialog(LPSTR lpFilename)
{
OPENFILENAME of;
char szFilter[] = "Music Files (*.ogg)\0*.ogg\0Image Files (*.png)\0*.png\0All files (*.*)\0*.*\0\0";
char szFile[MAX_PATH] = "\0";
char szTitle[] = "Select a file";
char szExt[] = "ogg";
of.lStructSize = sizeof(of);