Skip to content

Instantly share code, notes, and snippets.

View Miliox's full-sized avatar

Emiliano Firmino Miliox

View GitHub Profile
@Miliox
Miliox / gist:ac47e42c4c7997e32d84
Created November 15, 2015 14:09
Python Milliseconds to Date
from datetime import datetime,deltatime
s = str(1447564962575)
date = datetime.fromtimestamp(float(s[0:-3]))
milli = int(s[-3:])
@Miliox
Miliox / crc32.c
Created November 13, 2015 18:28
MPEG2 CRC32
#include <sys/types.h>
#include "crc32.h"
// CRC32 lookup table for polynomial 0x04c11db7
static u_long crc_table[256] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
@Miliox
Miliox / gist:f72e6baf61e208e7659a
Created November 12, 2015 13:31
Get Android IP using adb shell
adb shell netcfg | head -n 1
@Miliox
Miliox / tobin.c
Created November 5, 2015 14:45
ToBinary
// http://gynvael.coldwind.pl/n/c_cpp_number_to_binary_string_01011010
void to_bin(unsigned char c, char *out) {
*(unsigned long long*)out = 3472328296227680304ULL +
(((c * 9241421688590303745ULL) / 128) & 72340172838076673ULL);
}
@Miliox
Miliox / tutorial.md
Created October 2, 2015 12:54
Mount Windows Shared Folder on Linux

How mount Windows Shared folder on Linux

Installation

´´´sh sudo apt-get install cifs-utils ´´´

Mount Shared Folder

@Miliox
Miliox / gist:8808ebbc74ad1396f956
Created September 26, 2015 21:23
Create LiveBoot USB using CLI on MacOSX
# source: https://blog.tinned-software.net/create-bootable-usb-stick-from-iso-in-mac-os-x/
$ hdiutil convert -format UDRW -o livecd.img LiveCD.iso
$ diskutil list
$ diskutil partitionDisk /dev/disk<n> 1 "Free Space" "unused" "100%"
$ diskutil unmount disk<n>s1
$ sudo dd if=antivirus_livecd.img.dmg of=/dev/disk<n> bs=1m
$ diskutil eject /dev/disk<n>
@Miliox
Miliox / ms.sh
Created September 14, 2015 15:06
Unix like MS[Build] function for Bash
alias msbuild="/c/Program\ Files\ \(x86\)/MSBuild/14.0/Bin/MSBuild.exe"
function ms() {
local count_sln=`ls -1 *.sln 2>/dev/null | wc -l`
if [[ $count_sln -eq 0 ]]; then
echo "error: no solution in directory"
return 1;
fi
local alias_is_set=`alias | grep msbuild | cut -d '=' -f 2 | tr -d "'"`
@Miliox
Miliox / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@Miliox
Miliox / gist:d3c55177ae0c7abac6b8
Last active August 29, 2015 14:25
guid to cout
std::ostream& operator<<(std::ostream& os, REFGUID guid)
{
char buffer[37];
snprintf(buffer, sizeof(buffer),
"%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX",
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
return os << buffer;
@Miliox
Miliox / topn_lite.cpp
Created April 14, 2015 01:33
Find Top N Words from a Text File
/*
* topn_lite.cpp
* Copyright (C) 2015 Emiliano Firmino <emiliano.firmino@gmail.com>
*
* Distributed under terms of the MIT license.
*/
#include <algorithm>
#include <iostream>
#include <fstream>