Skip to content

Instantly share code, notes, and snippets.

View boogie666's full-sized avatar

Bogdan Bugarschi boogie666

  • Timisoara
View GitHub Profile
import java.util.Scanner;
public class TicTacToe {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
char player = '0';
char[][] board = emptyBoard();
@boogie666
boogie666 / default_user.patch
Created January 10, 2020 13:30
A Simple Patch for the lightdm-tiny-greeter that adds a default user config
diff --git a/config.h b/config.h
index 00458f2..1585fa1 100644
--- a/config.h
+++ b/config.h
@@ -4,6 +4,8 @@
static const char *user_text = "Username";
/* Password prompt text */
static const char *pass_text = "Password";
+/* Default User */
+static const char *default_user = "";
// sa zicem ca o avem o functie "cube" care facem un cub de latura L la pozitia (x,y,z)
function cube(x,y,z,L){
console.log("cub de latura", L, "la",x,y,z);
}
// si o functie generica care face fibonacci pana la 'count'
// adica primele 100 de numere din sir, sa zicem
@boogie666
boogie666 / Main.java
Created June 6, 2019 15:48
Agenda Saracului
package com.itschool.agendaSaracului;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@boogie666
boogie666 / Main.java
Last active May 30, 2019 13:06
X si Zero in Java
package com.boogie666.tictactoe;
import java.util.Scanner;
public class Main {
private static char X = 'X';
private static char ZERO = 'O';
private static char NIMIC = '-';
private static char[][] tabla = {
@boogie666
boogie666 / full-example.js
Last active May 15, 2019 10:17
Full code example
//define the finite state machine data structure...
let fsm = {
"checkLogin" : {"valid" : "login",
"invalid" : "showError"}
};
//create the handler functions...
function checkLogin(state){
if(state.data.username == "admin"){
return {
@boogie666
boogie666 / fsm-state-runner.js
Last active May 15, 2019 10:06
fsm state runner 'api'
function checkLogin(state){
if(state.data.username == "admin"){
return {
...state,
transitionTo: "valid"
};
}else {
return {
...state,
transitionTo: "invalid"
@boogie666
boogie666 / run-fsm.js
Created May 15, 2019 09:59
simple finite state machine runner
function run(fsm, stateRunner, state){
let runner = stateRunner[state.currentState];
return Promise.resolve(runner(state)).then(function(transition){
if(transition.transitionTo === "done"){
return transition.data;
}
return run(fsm, stateRunner, {
...transition,
currentState: fsm[state.currentState][transition.transitionVia]
});
(defn- -create-react-component
"create a 'inline' component and set the display name to the same name as the function"
[f]
(let [component (fn [js-props]
(let [args (.-uixprops js-props)]
(hiccup->react (apply f args))))]
(set! (.-displayName component) (.-name f))
component))
;; obvious optimization if obvious
@boogie666
boogie666 / index.js
Created May 24, 2018 09:30
Finding pairs in a stream of data using windowing
require("./array.js");
const { reduce, reduced } = require("./reduce.js");
const { map, dropWhile, dedupe, window, comp } = require("./transducers.js");
const { into } = require("./into.js");
function pair_items(items){
items = into([], dropWhile(x => x.hasOwnProperty("pair_id")), items);
var first = items[0];
items.shift();