Skip to content

Instantly share code, notes, and snippets.

@haxelion
haxelion / t4.hs
Last active August 29, 2015 13:59
Haskell solution for the google codejam 2013 qualification round problem "Tic-Tac-Toe-Tomek"
import Data.List
import Data.String
import Text.Read
import System.Environment
import System.IO
hReadCount :: Handle -> IO(Int)
hReadCount input = do
l <- hGetLine input
return (read l :: Int)
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/mman.h>
#include <sys/wait.h>
int funTime1()
{
int r;
% f : frequency array
% a : amplitude array
% p : phase array
% pm : phase margin
% fp : phase margin frequency
% str : title of the plot
function phasegainplot(f, a, p, Pm, Fp, str)
figure;
subplot(2, 1, 1);
semilogx(f, a);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void server(int sock)
extern crate sha;
use std::default::Default;
use sha::sha1::Sha1;
use sha::utils::{Digest, DigestExt};
use std::thread;
use std::iter;
use std::str::StrExt;
use std::str;
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#![feature(simd)]
extern crate rand;
extern crate time;
mod lin_alg;
use lin_alg::Quat;
use rand::Rng;
fn main(){
let mut rng = rand::XorShiftRng::new_unseeded();
mov ebx, [esp+8] ; stock l'adresse de la matrice dans ebx
mov ecx, [esp+12]; je sais pas où il devrait y avoir la longueur de la matrice, on le met dans ecx
add ecx, ebx ; on calcul l'adresse de fin de la matrice
loop:
mov dl, [ebx] ; on met les 8 bits d'un élément dans edx
not dl ; on inverse ces 8 bits
mov [ebx], dl ; on les remets dans la matrice
inc ebx ; on va à l'élément suivant
cmp ebx, ecx ; est-on à la fin de la matrice ?
jne loop ; si non continuer la boucle
@haxelion
haxelion / Resolve Relocation.py
Created October 12, 2016 09:37
Hopper v3 script to resolve relocation using readelf and c++filt. Put it in Hopper script directory to use it (under linux ~/GNUstep/Library/ApplicationSupport/Hopper/Scripts)
import subprocess
import re
doc = Document.getCurrentDocument()
segment = doc.getCurrentSegment()
binary = doc.getExecutableFilePath()
mangled = subprocess.check_output(['readelf', '-rW', binary])
filt = subprocess.Popen(['c++filt'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
output = filt.communicate(mangled)
import sys
import os
import tempfile
import binascii
from PIL import Image
if __name__ == '__main__':
filename = sys.argv[1]
tempdir = tempfile.mkdtemp()
temppath = tempdir + os.path.basename(filename)