Skip to content

Instantly share code, notes, and snippets.

View avgprog's full-sized avatar

avgprog

View GitHub Profile
@avgprog
avgprog / ExpressionParser.scala
Created May 8, 2022 09:17
Sample scala code for parsing user-defined expressions
/*
Description: Parses expressions with two user-defined functions ("Max","Sum") and one operator ("+") acting upon three lists:
"l1", "l2", "l3"
Sample expression which can be parsed by this program:
Sum(Max(l1,l2),l3)+Max(l1,Sum(l1,l2)+l3)
To know more or to create your own parsers, visit:
http://www.artima.com/pins1ed/combinator-parsing.html
*/
import scala.util.parsing.combinator._
@avgprog
avgprog / ConwayGameOfLife.java
Created May 8, 2022 09:12
Conway's game of life visualisation implemented using JavaFX
/*
This code implements Conway's game of life, the universe of which is a two dimensional grid of cells which can either be dead or alive.
The grid changes its state based on these rules:
1) Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
2) Any live cell with two or three live neighbours lives on to the next generation.
3) Any live cell with more than three live neighbours dies, as if by overpopulation.
4) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
In this case, color of a live cell is black and color of a dead cell is white.
Sample input 1:
10
@avgprog
avgprog / .conkyrc
Last active July 11, 2022 21:25
.conkyrc updated
conky.config = {
--Various settings
background = false,
cpu_avg_samples = 2,
diskio_avg_samples = 10,
double_buffer = true,
if_up_strictness = 'address',
net_avg_samples = 2,
@avgprog
avgprog / .conkyrc
Last active July 11, 2022 21:26
Conky file for generating a cool desktop widget
conky.config = {
--Various settings
background = false,
cpu_avg_samples = 2,
diskio_avg_samples = 10,
double_buffer = true,
if_up_strictness = 'address',
net_avg_samples = 2,
@avgprog
avgprog / Instructions
Created August 21, 2020 00:15
Running Ubuntu Touch on SM-T515NZKDINU
My device details:
Device Model Number: SM-T515NZKDINU
Linux Kernel Version: 4.4.111-17420370
Instructions for SM-T515:
1) Download these files using the links given in the post: https://forum.xda-developers.com/galaxy-tab-a/development/ubports-ubuntu-touch-sm-t510-t515-t4146417:
a) Halium arm32 GSI file
b) Ubports Patched Kernel
c) (Optional) SamsungUSBTethering zip
@avgprog
avgprog / tf_som_classifier.py
Created December 18, 2017 04:56
Tensorflow SOM implementation
# coding: utf-8
# In[1]:
from tensorflow.examples.tutorials.mnist import input_data
# In[2]:
@avgprog
avgprog / CustomTypeInference.scala
Created February 8, 2017 04:57
Scala custom datatype detection using regex parser
object CustomTypeInference {
def main(args: Array[String]) = {
val input_string_list = List("22-12-2016","2.334e10","2.345","-1234","-1","1.e10","25/12/16","21-21-16","21/21/2016")
// Date format of the type can be detected: DD-MM-YYYY | DD-MM-YY | DD/MM/YYYY | DD/MM/YY
val dateRegex = """([0-9]{2}-[0-9]{2}-[0-9]{4}|[0-9]{2}-[0-9]{2}-[0-9]{2}|[0-9]{2}/[0-9]{2}/[0-9]{4}|[0-9]{2}/[0-9]{2}/[0-9]{2})"""
val timeRegex = """([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})"""