Skip to content

Instantly share code, notes, and snippets.

View mhtocs's full-sized avatar
🌱
learning

Arvind M. mhtocs

🌱
learning
  • Zoho
  • Chennai
View GitHub Profile
@mhtocs
mhtocs / trigram.rs
Created October 16, 2023 13:51
Trigrams
#[test]
fn test_trigram() {
let trigrams = trigram("Hello, wor杯ld!");
assert_eq!(
trigrams,
vec![
"hel", "ell", "llo", "lo,", "o, ", ", w", " wo", "wor", "or杯", "r杯l", "杯ld", "ld!"
]
);
}
@mhtocs
mhtocs / mario.rs
Created September 29, 2023 06:51
Mario
// SUPER-MARIO STATE MACHINE IN RUST
#[derive(Debug, PartialEq)]
enum State {
Mario,
SuperMario,
FireMario,
CapeMario,
}
@mhtocs
mhtocs / CounterApp.js
Created March 4, 2022 19:35
A counter in ReactJS
import React from "react";
import ReactDOM from "react-dom";
const App = () => {
const [counter, setCounter] = React.useState(0);
return (
<div>
<h2>Counter: {counter}</h2>
@mhtocs
mhtocs / App.js
Created March 4, 2022 19:20
React data-binding demo
import React from 'react';
import ReactDOM from 'react-dom';
function App() {
const [number1, setNumber1] = React.useState();
const [number2, setNumber2] = React.useState();
const [total, setTotal] = React.useState(0);
let calculateTotal = () => setTotal(number1 + number2);
@mhtocs
mhtocs / game.ex
Created January 21, 2022 17:10
A tiny game in elixir
# bread
defmodule Game do
def play do
hints = "flour, water, yeast, bakery"
IO.puts "Hints: #{hints}"
guess = IO.gets "Guess the word: "
guess = String.trim guess
attempt guess
end
@mhtocs
mhtocs / keybase.md
Created March 11, 2021 05:42
Proof for keybase
@mhtocs
mhtocs / coc-settings.json
Last active October 8, 2023 15:43
my nvim config
{
"coc.preferences.formatOnSaveFiletypes": ["rust", "py", "yaml", "json"],
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black"
}
@mhtocs
mhtocs / list_callables_2.py
Created April 19, 2020 14:50
List all callables with exception handling
import math #import whatever
def list_callables(module):
all = []
for k,v in module.__dict__.items():
if callable(v):
try:
all.append(v.__name__)
except:
@mhtocs
mhtocs / list_callables.py
Created April 19, 2020 14:41
To list all callables
import math
list_callables = lambda module : [ v.__name__ for k,v in module.__dict__.items() if callable(v)]
all_math_function = list_callables(math) #list_callables accepts a module name, the module (here math) must be imported already
print(all_math_function)
@mhtocs
mhtocs / post-install.md
Last active August 15, 2019 22:03
Crunchbang++ Inspiron 11 3000 Series

Mouse Tap and Natural Scrolling

/usr/share/X11/xorg.conf.d/40-libinput.conf

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
	Option "Tapping" "on"