Skip to content

Instantly share code, notes, and snippets.

View karimkawambwa's full-sized avatar
🙃
doing something

Karim karimkawambwa

🙃
doing something
  • Bagamoyo, Tanzania
View GitHub Profile
@karimkawambwa
karimkawambwa / cnc_mill.cpp
Last active December 18, 2015 22:18
CNC MILLING MACHINE ROBOT C by KARIM, HAMRIT, ZAIN and JADEN
const int XDir = -1;
const int XLength = 550;
const int XRes = 4; // X Resolution count per step
const int XPwr = 5; // X axis movement power only during mill
const int XzeroPwr = 20;
const int XOffset = -100;
const int YDir = 1;
const int YLength = 470;
const int YRes = 9; // Y Resolution count per step
@karimkawambwa
karimkawambwa / bitmaps_util.brs
Last active October 4, 2018 18:45
Roku BrightScript Bitmap Cache roTextureManager talk to roBitmap. Note: You must have a textureManager on your GlobalAA.
function CreateBitmap(options)
'first attempt
bitmap = CreateObject("roBitmap", options)
if bitmap = invalid
gg = GetGlobalAA()
gg.textureManager.Cleanup()
'second attempt
bitmap = CreateObject("roBitmap", options)
end if
return bitmap
@karimkawambwa
karimkawambwa / Int2Hex_String_RokuBrightScript
Last active October 25, 2015 17:46
Integer to Hex String Roku BrightScript
' @param intValue positive integers from 0 onwards
function IntHexString(intValue as Integer) as String
this = {}
this.hexString = function(int) as String
num = int/16.0
remainder = (num mod 1) * 16.0
result = fix(num)
if remainder > 15
hex = m.hexString(remainder)
@karimkawambwa
karimkawambwa / rideshare_posts.py
Last active July 9, 2018 19:53
Facebook Rideshare data collection using selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
@karimkawambwa
karimkawambwa / camfix .bashrc
Created August 23, 2018 17:11 — forked from eliotsykes/camfix .bashrc
camfix - Terminal command to fix Mac OS X built-in webcam
#!/bin/bash
# Add to your .bashrc on Mac OSX, then run camfix in Terminal
# if the Mac's built-in camera stops working.
# Thanks to: http://osxdaily.com/2013/12/27/fix-there-is-no-connected-camera-error-mac/
alias camfix='sudo killall VDCAssistant; sudo killall AppleCameraAssistant'
@karimkawambwa
karimkawambwa / minimax.py
Created November 1, 2018 09:44
Minimax Algorithm
import math
board = [['_','_','_'],['_','_', '_'],['_','_','_']]
def wins(state, player):
win_state = [
[state[0][0], state[0][1], state[0][2]],
[state[1][0], state[1][1], state[1][2]],
[state[2][0], state[2][1], state[2][2]],
[state[0][0], state[1][0], state[2][0]],
@karimkawambwa
karimkawambwa / zoomtanzania_scraper.md
Created November 2, 2018 09:27
zoomtanzania classifieds scraping for analysis

Scraping ZoomTanzania Cars

The following code is used to scrape car the classifieds car dataset to be used in analysis.

First we are going to setup a table in an sqllite database so tht we can persit store our scraped data incase my computer dies because my battery needs to be replaced or if we lose internet connection because for some reson there is only one spot in the house here in Bagamoyo that has proper network, miss that spot and hello stone age!

import sqlite3
@karimkawambwa
karimkawambwa / CssRenderer.py
Created May 15, 2019 06:13
django rest framework css renderer
from rest_framework.renderers import BaseRenderer
class CSSRenderer(BaseRenderer):
media_type = 'text/css'
format = 'css'
charset = 'utf-8'
render_style = 'text'
def render(self, data):
return data
@karimkawambwa
karimkawambwa / charts.js
Last active July 4, 2019 09:56
Implement Dependent/Chained Dropdown List with Django where the list comes from array field within another model. Simple is Better Than Complex.
document.addEventListener("DOMContentLoaded", () => {
const select = document.getElementById('chart-table');
const fields = JSON.parse(select.getAttribute('data-fields'));
const inputs = document.querySelectorAll('input[id^=chart-table-field_]');
[...inputs].forEach(input => {
console.log(input)
input.parentElement.parentElement.style.display = 'none';
});
{
"100": {
"brief": "Continue",
"extended": "The server has received the request headers, and the client should proceed to send the request body"
},
"101": {
"brief": "Switching Protocols",
"extended": "The requester has asked the server to switch protocols"
},
"103": {