Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
@danleyb2
danleyb2 / unixhttpc.go
Created Nov 14, 2020 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
View unixhttpc.go
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@laobubu
laobubu / ABOUT.md
Last active Apr 10, 2020
njq (No jQuery) use vanilla DOM API with jQuery-like functions.
View ABOUT.md

njq (No jQuery)

Vanilla JavaScript is good but the function names are too long. Now, you can use vanilla DOM API with jQuery-like functions.

Only ~1kB (without gzip) after uglifying. You can even tailor for yourself to make it much smaller, by deleting/adding modules. A good choice to manipulate DOM for side projects.

Document

@kekru
kekru / 1-Enable Docker Remote API with TLS client verification.md
Last active Apr 23, 2021
Docker Remote API with client verification via daemon.json
View 1-Enable Docker Remote API with TLS client verification.md

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@EvieePy
EvieePy / bot_example.py
Last active May 11, 2021
A Cogs Example for the rewrite version of - discord.py
View bot_example.py
import discord
from discord.ext import commands
import sys, traceback
"""This is a multi file example showcasing many features of the command extension and the use of cogs.
These are examples only and are not intended to be used as a fully functioning bot. Rather they should give you a basic
understanding and platform for creating your own bot.
These examples make use of Python 3.6.2 and the rewrite version on the lib.
@mikecrittenden
mikecrittenden / wget.sh
Last active May 15, 2021
Download an entire website with wget, along with assets.
View wget.sh
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
View Java8Sample.java
//before
Runnable r1 = new Runnable() {
@Override
public void run() {
System.out.println("My Runnable");
}
};
//now
Runnable r2 = () -> System.out.println("My Runnable");
@laobubu
laobubu / ABOUT.md
Last active May 13, 2021
A very simple HTTP server in C, for Unix, using fork()
View ABOUT.md

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@bradmontgomery
bradmontgomery / example.py
Created Aug 16, 2016
Example of setting a choices value for django ArrayField
View example.py
# Here's your list of choices that would be displayed in a drop-down
# element on the web. It needs to be a tuple, and we define this
# as a variable just for readability/convenience.
#
# This example has 3 choices, each of which consists of two parts:
# 1. the thing that get strored in your database
# 2. the thing that you see in a dropdown list
LABEL_CHOICES = (
('this gets stored in your database', 'This item is what you see in the drop-down'),
('django', 'Django'),
@danleyb2
danleyb2 / scratch_2
Created Jan 17, 2016
load Link header into a dictionary
View scratch_2
#!/usr/bin/env python3.4
#### Nyaundi Brian <ndieksman@gmail.com>
from pprint import pprint
links_string_from_header='<https://api.github.com/search/users?q=location%3AKenya&page=4>; rel="next",' \
' <https://api.github.com/search/users?q=location%3AKenya&page=34>; rel="last", ' \
'<https://api.github.com/search/users?q=location%3AKenya&page=1>; rel="first", ' \
'<https://api.github.com/search/users?q=location%3AKenya&page=2>; rel="prev"'
View SpriteSheetAnim.java
package anim;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JFrame;