Skip to content

Instantly share code, notes, and snippets.

View aulisius's full-sized avatar
🏠
Working from home

​Faizaan aulisius

🏠
Working from home
View GitHub Profile
@aulisius
aulisius / fizzbuzz.rs
Created February 3, 2016 01:09
FizzBuzz in Rust
fn main() {
(1..100)
.filter(|&x| x % 3 == 0 || x % 5 == 0)
.map(|x| {
let mut str = String::new();
if x % 3 == 0 {
str.push_str("Fizz");
}
if x % 5 == 0 {
str.push_str("Buzz");
@aulisius
aulisius / code.l
Created September 14, 2016 00:30
Minimal code generation using Flex and YACC
%{
#include "y.tab.h"
%}
alpha [A-Za-z]
digit [0-9]
%%
[\t \n]
const Compose = ({ children = () => null, ...chain }) => {
const composedFn = Object.entries(chain).reduce(
(acc, [renderProp, renderFn]) => props =>
renderFn(value => acc({ ...props, [renderProp]: value })),
children
);
return composedFn();
};
import java.util.*;
import java.util.stream.*;
class Trie {
public char nodeChar;
public boolean isLeaf;
public List<String> safeNames;
public HashMap<Character, Trie> subtrie;
Trie(char nodeChar, boolean isLeaf) {
@aulisius
aulisius / eval.js
Last active October 18, 2018 11:38
Evaluate mathematical expression
function getPrecedence(token) {
const Precedence = { HIGH: 3, MED: 2, LOW: 1, ZERO: 0 }
switch (token) {
case '+':
case '-':
return Precedence.ZERO
case '*':
case '/':
case '%':
@aulisius
aulisius / webpack.config.js
Created April 5, 2019 02:14
DynamicCDNWebpackPlugin with custom resolver for React (CDN as jsDelivr)
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DynamicCdnWebpackPlugin = require("dynamic-cdn-webpack-plugin");
module.exports = {
mode: "production",
plugins: [
new HtmlWebpackPlugin(),
new DynamicCdnWebpackPlugin({
resolver: (packageName, packageVersion, options) => {
let env = options.env || "development";
@aulisius
aulisius / widgets.js
Last active April 12, 2020 15:48
how an order is defined
let widgets = [
{
name: "widgetA",
dependencies: [{ endpoint: "endpointA", reloadableActions: ["action 1"] }],
},
{
name: "widgetB",
dependencies: [{ endpoint: "endpointA", reloadableActions: ["action 1"] }],
},
{
@aulisius
aulisius / Dockerfile
Last active April 23, 2020 07:41
Setup Confluent Platform Kafka on OpenShift/k8s
FROM confluentinc/cp-server-connect
RUN confluent-hub install debezium/debezium-connector-postgresql:0.10.0 --no-prompt
RUN confluent-hub install debezium/debezium-connector-mysql:1.1.0 --no-prompt
@aulisius
aulisius / cypress-blink-diff.js
Created August 18, 2020 08:35
Cypress Blink Image Diff Plugin
@aulisius
aulisius / DatabaseHelper.md
Created October 14, 2016 16:44
Android Lab essentials

The [SQLiteOpenHelper] is a

A helper class to manage database creation and version management.

It might feel complicated, but once you understand how to use it, you would (hopefully) prefer [SQLiteOpenHelper] to multiple db.rawQuerys.

I'll explain with the help of Login and Signup activities. We'll probably get something similar for the assess. So, two birds in one stone. :)


The (only) proper way of using SQLiteOpenHelper is to extend and override some of its methods namely - onCreate, onUpgrade