Skip to content

Instantly share code, notes, and snippets.

View geofmureithi-zz's full-sized avatar

Njuguna Mureithi geofmureithi-zz

View GitHub Profile
#import <WebKit/WebKit.h>
#include "ui.h"
#include "ui_darwin.h"
#define uiWebViewSignature 0x57656276 // "Webv"
typedef struct uiWebView uiWebView;
#define uiWebView(this) ((uiWebView *) (this))
struct uiWebView {
@eLement87
eLement87 / mqtt_tls_working.ino
Created December 10, 2017 13:12
ESP8266 Secure MQTT Connection with Client Certificate Authentication
#include <FS.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <time.h>
// Insert your FQDN of your MQTT Broker
#define MQTT_SERVER "mqtt.srvx1.local"
const char* mqtt_server = MQTT_SERVER;
@geofmureithi-zz
geofmureithi-zz / pretty-json.php
Created April 20, 2016 16:49
Pretty-print a JSON string in PHP.
<?php
/**
* Formats a JSON string for pretty printing
*
* @param string $json The JSON to make pretty
* @param bool $html Insert nonbreaking spaces and <br />s for tabs and linebreaks
* @return string The prettified output
* @author Jay Roberts
*/
@mzabriskie
mzabriskie / nps.js
Created September 8, 2015 19:01
Calculate Net Promoter Score
// Expects an array of scores from 0-10
// Example: nps([10, 9, 10, 4]); -> 50
// See http://www.medallia.com/net-promoter-score/
function nps(scores) {
var promoters = 0;
var detractors = 0;
for (var i=0, l=scores.length; i<l; i++) {
if (scores[i] >= 9) promoters++;
if (scores[i] <= 6) detractors++;
@mannodermaus
mannodermaus / BaseAdapter.java
Last active June 14, 2023 14:24
RecyclerView.ViewHolder and Adapter demonstration
public abstract class BaseAdapter<T, VH extends BaseViewHolder<T>> extends RecyclerView.Adapter<VH> {
private List<T> items;
// Missing: setItems(), addItem(), removeItem(), ...
@Override
public final void onBindViewHolder(VH vh, int position) {
T item = items.get(position);
vh.performBind(item, position);
@debanjum
debanjum / Quote
Created March 5, 2014 06:23
Extracts Quotes from GoodReads. Stores text file in Variety compatible format
#!/bin/sh
# Initialising Variables [Enter You Use Name in place of USER]
quotesdir='/home/USER/.config/variety/pluginconfig/quotes/quotes.txt'
# New Quotes: Clean Earlier Quotes
[[ $# -eq 1 && $1 == 'New' ]] && ( `mv -f "$quotesdir" /tmp/quotes_old.txt` )
# Restore Earlier Quotes
[[ $# -eq 1 && $1 == 'Restore' ]] && ( `mv -f /tmp/quotes_old.txt "$quotesdir"` )
# Quote Help
@CHH
CHH / 00_rfc_decorators.md
Last active November 22, 2024 14:48
PHP Decorators RFC

PHP Decorators (alternative proposal to Annotations)

Inspiration: Python Decorators

Todo

  • Further refine how class decorators should work. Should they work on the instance level? Or should they just receive the class name, and can only be used for providing metadata? Instance level is probably the only one that makes sense in PHP. Problem is though, that then the decorator is not called when used in the declaration.
@jeremywrowe
jeremywrowe / gist:3506869
Created August 29, 2012 04:33
highcharts - show label for first and last data points in a series
plotOptions: {
line : {
dataLabels : {
enabled : true,
formatter: function() {
var first = this.series.data[0],
last = this.series.data[this.series.data.length - 1];
if ((this.point.category === first.category && this.point.y === first.y) ||
(this.point.category === last.category && this.point.y === last.y)) {
return this.point.y;
@ScottPhillips
ScottPhillips / createqrcode.php
Created February 1, 2011 20:55
Create a QR Code using PHP and Google
function createQR($url,$size ='150',$evLevel='L',$margin='0') {
$url = urlencode($url);
return '<img src="http://chart.apis.google.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $evLevel . '|' . $margin . '&chl=' . $url . '" alt="QR code" width="' . $size . '" height="' . $size . '"/>';
}
echo createQR('http://www.wickedbrilliant.com',150);