Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / gitstats.sh
Created November 5, 2012 21:35
Git - calculate how many lines of code were added/changed by someone
# Run this in the project repo from the command-line
# http://stackoverflow.com/a/4593065/99923
git log --shortstat --author "Xeoncross" --since "2 weeks ago" --until "1 week ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
@xeoncross
xeoncross / mysql.py
Last active February 16, 2024 03:10
Example database class for wrapping mysql-connector for python
import mysql.connector
# from mysql.connector import Error
# pip3 install mysql-connector
# https://dev.mysql.com/doc/connector-python/en/connector-python-reference.html
class DB():
def __init__(self, config):
self.connection = None
self.connection = mysql.connector.connect(**config)
@xeoncross
xeoncross / calendar.php
Last active February 7, 2024 20:30 — forked from agarzon/calendar.php
Simple PHP calendar using bootstrap
<?php
function build_calendar($month, $year) {
$daysOfWeek = array('S','M','T','W','T','F','S');
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);
$numberDays = date('t',$firstDayOfMonth);
$dateComponents = getdate($firstDayOfMonth);
$monthName = $dateComponents['month'];
$dayOfWeek = $dateComponents['wday'];
$calendar = "<table class='calendar table table-condensed table-bordered'>";
@xeoncross
xeoncross / gencert.go
Created January 27, 2024 17:14
Generate a self-signed certificate in Go
package main
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
@xeoncross
xeoncross / channels.go
Created February 12, 2018 22:39
Fastest way to merge multiple channels in golang.
package main
import (
"fmt"
"sync"
"sync/atomic"
)
// Fill Channel with int values
func fillChan(number int) <-chan int {
@xeoncross
xeoncross / email_mime.go
Last active December 29, 2023 03:41
Example of parsing a mime email message with Go (original: https://play.golang.org/p/v0QslNl5he)
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"mime"
"mime/multipart"
@xeoncross
xeoncross / cr2_to_video.sh
Last active December 15, 2023 13:06
Converting a folder of .CR2 (Canon Raw Images) into a timelapse video on mac or linux
# Assuming your have installed the following:
#
# brew install ufraw imagick ffmpeg
# apt-get install ufraw imagick ffmpeg
# Convert to JPG's
for img in *.CR2; do convert -resize 1920 "$img" "$img.jpg"; print "$img"; done
# Make a video
@xeoncross
xeoncross / http.php
Created October 24, 2017 01:49
POST requests using curl, sockets, and php-curl
<?php
// command line
// curl --data "text=foobar" http://localhost:3001/api/decrypt
// File sockets
function http_request($url, $data, $a = null, $b = null) {
$opts = array('http' =>
array(
'method' => 'POST',
@xeoncross
xeoncross / mail.go
Last active November 5, 2023 10:58
Simple SMTP mail sender in golang that can send email directly to anyone. Super basic, but great for sending notice emails. Upgrades to STARTTLS if it can.
package main
import (
"encoding/base64"
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"strings"
@xeoncross
xeoncross / ssr_test.go
Created June 1, 2019 20:19
Example of using chromedp to prerender a create-react-app frontend using fake SSR via chrome headless
package main
import (
"context"
"io/ioutil"
"log"
"strings"
"testing"
"github.com/chromedp/cdproto/dom"