Skip to content

Instantly share code, notes, and snippets.

View manvscode's full-sized avatar
💭
Coding.

Joe Marrero manvscode

💭
Coding.
View GitHub Profile
@manvscode
manvscode / gdbinit
Last active August 29, 2015 14:17 — forked from CocoaBeans/gdbinit
# INSTALL INSTRUCTIONS: save as ~/.gdbinit
#
# DESCRIPTION: A user-friendly gdb configuration file.
#
# REVISION : 7.3 (16/04/2010)
#
# CONTRIBUTORS: mammon_, elaine, pusillus, mong, zhang le, l0kit,
# truthix the cyberpunk, fG!, gln
#
# FEEDBACK: https://www.reverse-engineering.net
@manvscode
manvscode / Pointers are not the same as arrays!
Created September 25, 2012 20:42
I had to convince my coworker about this. Pointers are not the same as arrays!
#include <stdio.h>
int main()
{
char myarray[ 256];
const char* mystring = "Hello my peeps.";
size_t array_size = sizeof(myarray);
size_t string_size = sizeof(mystring);
@manvscode
manvscode / hello-world.s
Created November 4, 2012 02:26
Hello World
# as -o hello-world.o hello-world.s ; ld -o hello-world hello-world.o
.data
hello_world_str: .ascii "Hello World!\n"
hello_world_len: .int 13
.text
.globl _start
_start:
movl $4, %eax # load sys call 4 into EAX
@manvscode
manvscode / endian.c
Created April 26, 2013 19:58
Versatile functions for converting endianess.
typedef union two_bytes {
unsigned short s;
unsigned char bytes[ 2 ];
} two_bytes_t;
int is_big_endian( void )
{
two_bytes_t check;
check.s = 1;
@manvscode
manvscode / scrap-emails.rb
Created April 26, 2013 20:00
Scrap emails in Ruby.
#!ruby
require 'net/http'
require 'uri'
def scrapEmails( urlString )
url = URI.parse( urlString )
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
emails = res.body.scan( /[A-Za-z0-9]+[@ | (at) | (AT) ][A-Za-z0-9]+\.[A-Za-z]+/i )
return emails
@manvscode
manvscode / subtle-bug.c
Created April 26, 2013 20:01
A subtle bug--what is the output?
#include <stdio.h>
int array[]={ 34, 2, 54, -6, -49};
#define S sizeof(array)/sizeof(array[0])
int main()
{
int d = -1;
@manvscode
manvscode / default.conf
Created April 30, 2017 12:30
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
@manvscode
manvscode / BigDecimal.cs
Created April 8, 2019 04:43 — forked from JcBernack/BigDecimal.cs
BigDecimal
using System;
using System.Numerics;
namespace Common
{
/// <summary>
/// Arbitrary precision decimal.
/// All operations are exact, except for division. Division never determines more digits than the given precision.
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d
/// Based on https://stackoverflow.com/a/4524254
/// <summary>
/// Fast exponential approximation.
/// </summary>
/// <remarks>
/// Based on "A Fast, Compact Approximation of the Exponential Function" by Nicol N.Schraudolph (1999)
/// <code>e^x ~ a*x + b
/// a = 2 ^ (mantissa bits) / ln(2) ~ 12102203
/// b = (exponent bias) * 2^(mantissa bits) ~ 1065353216</code>
/// </remarks>
/// <param name="x">A number specifying a power.</param>
@manvscode
manvscode / docker-cleanup-resources.md
Created November 26, 2019 23:05 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm