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','+','/' };
#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 = "";
}
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
#!/bin/bash
#############
# FUNCTIONS
#############
function h1 {
echo
echo "###################"
echo "## $1"
@niceboy120
niceboy120 / youtube.py
Created February 18, 2013 14:05 — forked from minrk/youtube.py
from IPython.core.display import display
class YouTubeVideo(object):
"""Class for embedding a YouTube Video in an IPython session, based on its video id.
e.g. to embed the video on this page:
http://www.youtube.com/watch?v=foo
you would do:
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 2
Comment=Edit text files
Exec=/usr/local/sublime-text-2/sublime_text
Icon=/usr/local/sublime-text-2/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"