Skip to content

Instantly share code, notes, and snippets.

Avatar

Italo Nicola nyeecola

View GitHub Profile
View main.rs
extern crate rand;
use rand::Rng;
struct Vec2 {
x: f32,
y: f32,
}
const POINTS_LEN: usize = 100_000;
View main.c
#include <SDL2/SDL.h>
#include <pthread.h>
#include <stdlib.h>
#define POINTS_LEN 100000
#define THREAD_NUM 4
typedef struct {
float x;
float y;
@nyeecola
nyeecola / gist:cb3155a24c555101d44faff3c7e481c4
Created Mar 6, 2019
c version with pthreads without a thread pool
View gist:cb3155a24c555101d44faff3c7e481c4
#include <SDL2/SDL.h>
#include <pthread.h>
#include <stdlib.h>
#define POINTS_LEN 100000
#define THREAD_NUM 4
typedef struct {
float x;
float y;
View caesar.py
text = u'In cryptography, a Caesar cipher, also known as Caesar\'s cipher, the shift cipher, Caesar\'s code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.'
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
attempts = []
guessed = False
# there are 26 possible ceasar's cyphers "variations"
for i in range(0, 26):
# shift letters `i` times to the right
View caesar.py
text = u'Pmoi erc sxliv wsgmep qihme wmxi Jegifsso lew pirkxl viuymviqirxw alir mx gsqiw xs avmxmrk sr xli aepp, tvszmhmrk wxexyw, qiwwe kmrk erh gsqqirxmrk. Yrhivwxerhmrk lsa qerc glevegxivw csy ger ywi, irefpiw csy xs qsvi ijjigxmzipc ywi Jegifsso ew e fywmriww sv geqtem kr xssp. Tvmzexi qiwwekmrk mw sri sj xli qemr aecw xlex tistpi mrxivegx sr Jegifsso. Xlmw xcti sj hmvigx qiwwekmrk ger fi imxliv er mrw xerx qiwweki (glex), sv e vikypev iqemp-xcti qiwweki. Jsv fsxl mrwxerx erh vikypev qiwwekmrk, xlivi mw e 20,000 glevegxiv pmqmx. E Jegi fsso wxexyw qec lezi glevegxiv pmqmxw, fyx gsrwmhivmrk xlex mx mw ex 63,206 glevegxivw, yrpiww csy evi avmxmrk Aev erh Tiegi, csy wlsyph fi jmri. Jegifsso lew vemwih xlmw ryqfiv 12 xmqiw xs eggsqqshexi ywivw wxexyw erh jiihfego. Jegifsso aepp tswxw lezi e 5000 glevegxiv pmqmx, fyx xvyrgexmsr fikmrw ex 477 glevegxivw. Xlmw irefpiw wsqisri xs avmxi e xlsyklxjyp viwtsrwi sv gviexi wsqixlmrk wmqmpev xs e fps k. Er evie almgl mw vevipc ywih mr Jegifsso mw xli Rsxiw wigxmsr. Mx m
View caesar.py
text = u'Pmoi erc sxliv wsgmep qihme wmxi Jegifsso lew pirkxl viuymviqirxw alir mx gsqiw xs avmxmrk sr xli aepp, tvszmhmrk wxexyw, qiwwe kmrk erh gsqqirxmrk. Yrhivwxerhmrk lsa qerc glevegxivw csy ger ywi, irefpiw csy xs qsvi ijjigxmzipc ywi Jegifsso ew e fywmriww sv geqtem kr xssp. Tvmzexi qiwwekmrk mw sri sj xli qemr aecw xlex tistpi mrxivegx sr Jegifsso. Xlmw xcti sj hmvigx qiwwekmrk ger fi imxliv er mrw xerx qiwweki (glex), sv e vikypev iqemp-xcti qiwweki. Jsv fsxl mrwxerx erh vikypev qiwwekmrk, xlivi mw e 20,000 glevegxiv pmqmx. E Jegi fsso wxexyw qec lezi glevegxiv pmqmxw, fyx gsrwmhivmrk xlex mx mw ex 63,206 glevegxivw, yrpiww csy evi avmxmrk Aev erh Tiegi, csy wlsyph fi jmri. Jegifsso lew vemwih xlmw ryqfiv 12 xmqiw xs eggsqqshexi ywivw wxexyw erh jiihfego. Jegifsso aepp tswxw lezi e 5000 glevegxiv pmqmx, fyx xvyrgexmsr fikmrw ex 477 glevegxivw. Xlmw irefpiw wsqisri xs avmxi e xlsyklxjyp viwtsrwi sv gviexi wsqixlmrk wmqmpev xs e fps k. Er evie almgl mw vevipc ywih mr Jegifsso mw xli Rsxiw wigxmsr. Mx m
View gist:248f79f47c91461b822d62789cab82b2
int soma (a, b)
{
return a + b;
}
----------------------------
Outro arquivo: 'tests/test_soma.cs'
View gist:5e1ec0bb67f3498ab872fdeba48d115a
/**
* Retorna a soma de 'a' com 'b'. (2 inteiros)
*
* :param a: primeiro inteiro
* :param b: segundo inteiro
*
* :returns: a soma do primeiro inteiro com o segundo
*/
int soma (int a, int b)
{