Skip to content

Instantly share code, notes, and snippets.

@niceboy120
niceboy120 / continuous_cartpole.py
Created August 5, 2022 21:15 — forked from iandanforth/continuous_cartpole.py
Continuous Cartpole for OpenAI Gym
"""
Classic cart-pole system implemented by Rich Sutton et al.
Copied from http://incompleteideas.net/sutton/book/code/pole.c
permalink: https://perma.cc/C9ZM-652R
Continuous version by Ian Danforth
"""
import math
import gym
@niceboy120
niceboy120 / Base64.java
Created March 17, 2018 00:07 — forked from EmilHernvall/Base64.java
Simple base64-encoder for java
public class Base64
{
public static String encode(byte[] data)
{
char[] tbl = {
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };
@niceboy120
niceboy120 / Gruntfile.js
Last active August 29, 2015 14:14
grunt task php livereload
var grunt = require('grunt');
grunt.initConfig({
watch: {
php: {
files: ['src/**/*php', 'src/**/*js'],
tasks: ['default'],
options: {
#Kasiski-Babbage cryptanalysis to get the text encripted with Vigenere
import fractions
import functools
import re #Import regular expresions
from collections import Counter
#----------------------------------------------------------------------------------------------
#Search for the words with the given frecuency and length
# @originalString [string]: the original text
MAX_KEY_LENGTH = 20
PEAK_MIN_OFFSET = 4
NUM_LETTERS = 26
FIRST_LETTER = "A"
KEY_LENGTH_GUESS = 6
def index_of_coincidence(s, shift):
"""Find the index of coincidence of s with itself shifted by shift"""
public class Vigenere
{
//declare instance variables for text and keyword
private String pt = "";
private String key = "";
Vigenere(){ //default constructor
pt = "";
key = "";
}
alpha = 'abcdefghijklmnopqrstuvwxyz'
#alpha=[chr(i) for i in range(ord('a'), ord('z')+1)]
def codageCesar(t,n,d):
resultat = ''
alpha2 = alpha[len(alpha)-d:]+alpha[:len(alpha)-d]
for lettre in t:
resultat = resultat + alpha2[alpha.index(lettre)]
return resultat
@niceboy120
niceboy120 / gist:941a2344a220affbd655
Last active August 29, 2015 14:01
sublime3.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text_3/sublime_text %F
Icon=/opt/sublime_text_3/Icon/48x48/sublime-text.png
Terminal=false
public class Maze {
public int counter = 0;
public char[][] maze =
{{'#', '#', '#', '#', '#', '#', '#', '#', '#', '#'},
{'#', ' ', ' ', ' ', '#', ' ', '#', ' ', ' ', '#'},
{'#', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', '#'},
{'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
# Install https://github.com/rg3/youtube-dl/ first.
youtube-dl http://www.youtube.com/playlist\?list\=PLC0B137D835A3C970 -l --max-quality mp4