Skip to content

Instantly share code, notes, and snippets.

View mtvbrianking's full-sized avatar

Brian Matovu mtvbrianking

View GitHub Profile
@alotaiba
alotaiba / Arduino TCP Server
Created January 24, 2011 16:14
A simple TCP server written in Python to control the Arduino board, it receives the signals over TCP connection, and sends them to the Arduino board using serial.
#!/usr/bin/env python
#
# Copyright 2011 Abdulrahman Alotaiba
# http://www.mawqey.com/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@josephok
josephok / client.c
Last active September 6, 2018 08:51
a stream socket server & client demo
/*
** client.c -- a stream socket client demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
@mgirouard
mgirouard / guzzle-exceptions.md
Created July 17, 2016 00:36
GuzzleHttp Exception Hierarchy
  • GuzzleException
    • SeekException
    • TransferException
      • RequestException ( RequestInterface ; ResponseInterface | null )
        • TooManyRedirectsException
        • ConnectException
        • BadResponseException
          • ServerException
  • ClientException
#include <boost/thread.hpp>
#include <iostream>
using namespace std;
void ThreadFunction()
{
int counter = 0;
for(;;)
@scrubmx
scrubmx / Application.php
Created October 25, 2017 23:18
Register custom model events in laravel 5.5
<?php
namespace App\Models;
class Application extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
@tureki
tureki / json_encode-null-to-empty-string-1.php
Last active March 31, 2021 18:53
json_encode null to empty string.
$value = array(
"deep"=>1,
"data"=>null,
"node"=>array(
"deep"=>2,
"data"=>null,
"node"=>array(
"deep"=>3
)
),
@greut
greut / run.php
Created April 30, 2011 18:18
A web server in pure PHP (non-concurrent and concurrent)
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@ravibharathii
ravibharathii / Strong Password RegEx
Created October 29, 2012 18:03
A Regular Expression for a Strong Password
Description of this regular expression is as below:
Passwords will contain at least 1 upper case letter
Passwords will contain at least 1 lower case letter
Passwords will contain at least 1 number or special character
Passwords will contain at least 8 characters in length
Password maximum length should not be arbitrarily limited
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@dsheiko
dsheiko / strtr.js
Last active July 9, 2023 18:18
Java-script strtr — translate characters or replace substrings
/**
* strtr() for JavaScript
* Translate characters or replace substrings
*
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.2
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
**/