Skip to content

Instantly share code, notes, and snippets.

View danleyb2's full-sized avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
public string ImageToBase64(Image image,
System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.util.ArrayList;
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;
@danleyb2
danleyb2 / scratch_2
Created January 17, 2016 17:35
load Link header into a dictionary
#!/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"'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?php
// A simple PHP script demonstrating how to connect to MySQL.
// Press the 'Run' button on the top to start the web server,
// then click the URL that is emitted to the Output tab of the console.
$servername = getenv('IP');
$username = getenv('C9_USER');
$password = "";
$database = "c9";
$dbport = 3306;
# Show current git branch in prompt.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
LIGHT_GREEN="\[\033[1;32m\]"
LIGHT_GRAY="\[\033[0;37m\]"
L="\[\033[0;35m\]"
import requests
import json
url = 'https://api.github.com/some/endpoint'
payload = {'some': 'data'}
# Create your header as required
headers = {"content-type": "application/json", "Authorization": "<auth-key>" }
r = requests.put(url, data=json.dumps(payload), headers=headers)
[
[
"_m.a.i.c.a_",
1
],
[
"__elibarikidaniel_marando__",
1
],
[

Keybase proof

I hereby claim:

  • I am danleyb2 on github.
  • I am danleyb2 (https://keybase.io/danleyb2) on keybase.
  • I have a public key ASA3TCNVO1kXk46ZlvZ4tMvEflADiA7hkKiHHHEqb8JD7Ao

To claim this, I am signing this object: