Skip to content

Instantly share code, notes, and snippets.

View kevinmungai's full-sized avatar

Kevin Mungai kevinmungai

View GitHub Profile
@kevinmungai
kevinmungai / main.dart
Created January 1, 2020 23:25 — forked from felangel/main.dart
Bloc with SearchDelegate
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@kevinmungai
kevinmungai / file_io.clj
Created September 12, 2019 14:11 — forked from mfikes/file_io.clj
Async file io in Clojure
(ns api-server.file-io
(:use [clojure.tools.logging :only (info warn error)])
(:import (java.nio.channels CompletionHandler AsynchronousFileChannel)
(java.nio ByteBuffer)
(java.nio.file.attribute FileAttribute)
(java.nio.file StandardOpenOption)
(java.util.concurrent Executors))
(:require [clojure.core.async :as async :refer [chan go put! close!]]
[clojure.java.io :as io]))
@kevinmungai
kevinmungai / fsm_ussd.clj
Created September 11, 2019 15:41
finite state machine - ussd
(ns ussd.fsm-utils
(:require
[clojure.string :as str]
[clojure.edn :as edn]
[ussd.sms :as sms]))
(defn check-via
[via]
(let [choices (:choices (edn/read-string (slurp "../../ussd_fsm.edn")))]
(if (contains? choices via)
@kevinmungai
kevinmungai / using_shadow_cljs_with_react_native.md
Created June 16, 2019 09:04
Using Shadow CLJS with React Native

How to use Shadow CLJS with React Native

This guides does not assume you are using expo. It is not yet perfect, especially the hot reloading part but maybe shadow-cljs could be modified.

  1. Create the React Native Project
react-native init <NameOfYourProject>
@kevinmungai
kevinmungai / Curry.md
Created December 19, 2017 14:01
Understanding of how the curry function works in Haskell

Curry in Haskell

So today I am going to go through the function curry in Haskell. I am finding a hard time trying to understand it and this is my way of trying to understanding it.

First the type signature

This is what I get when I type in :t curry

curry :: ((a, b) -> c) -> a -> b -> c
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package areacalculator;
import javax.swing.*;
/**
*
@kevinmungai
kevinmungai / animationOpenGL.cpp
Created November 21, 2017 09:51
Animation in OpenGL
// We will be doing animation in OpenGL
// key concepts are:
// 1. the idle function - idle() will post a replaint and this will lead to activation of the display() function
// 2. Also we will be doing double buffering like this: glutInitDisplayMode(GLUT_DOUBLE);
// In addition we will be introducing other functions such as glPushMatrix, glPopMatrix and glSwapBuffers
#include <windows.h>
#include <GL/glut.h>
#include <GL/gl.h>
@kevinmungai
kevinmungai / checkersTranslated.cpp
Last active November 16, 2017 08:38
translation leading to checkers pattern
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h/* Initialize OpenGL Graphics */
void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
glViewport(0,0,1000,1000);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black and opaque
@kevinmungai
kevinmungai / transformationAssignment.cpp
Last active November 14, 2017 08:50
performing translation with OpenGL
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h/* Initialize OpenGL Graphics */
void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
glViewport(0,0,1000,1000);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black and opaque
}
@kevinmungai
kevinmungai / translationAssignment.cpp
Created November 14, 2017 08:26
Shows how to perform translation
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.hvoid
initGL() {
glMatrixMode(GL_MODELVIEW); //Set Matrices to MODELVIEW to support transformations
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
glViewport(0,0,640,480);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);