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 / float2bin.js
Last active February 1, 2024 06:56
Converts decimal float to binary 32 format float
// @author - {N.Md Faizaan}
// @email - {aulisius7[at]gmail[dot]com}
// @title - Converts decimal float to binary 32 format float
// @ref - https://en.wikipedia.org/wiki/Single-precision_floating-point_format
// @license - MIT
/**
* float2bin - Convert decimal number to binary32 format
* @param {input} - The number to be converted either in Number or String type
* @return {bin32float} - The binary32 representation
@aulisius
aulisius / autocomplete.c
Created December 27, 2015 07:32
Basic autocomplete using trie in C
//Basic autocomplete using a Trie
//The trie is really not efficient
//The words should be supplied in a dict.txt file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct n {
struct n *subtrie[26];
@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");
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 / 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]
@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

const Compose = ({ children = () => null, ...chain }) => {
const composedFn = Object.entries(chain).reduce(
(acc, [renderProp, renderFn]) => props =>
renderFn(value => acc({ ...props, [renderProp]: value })),
children
);
return composedFn();
};
@aulisius
aulisius / maybe.js
Created January 13, 2019 04:00
Scratchpad
function MaybeN(value) {
if (value.__type__ === "maybe") {
return value;
}
const isEmpty = () => value === undefined || value === null;
let internalMaybe = {};
internalMaybe = {
@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";