Skip to content

Instantly share code, notes, and snippets.

View flaviocopes's full-sized avatar

Flavio Copes flaviocopes

View GitHub Profile
View Visualize your local Git contributions with Go.md

Run go install and

  • gogitlocalstats -add /path/to/folder will scan that folder and its subdirectories for repositories to scan
  • gogitlocalstats -email your@email.com will generate a CLI stats graph representing the last 6 months of activity for the passed email. You can configure the default in main.go, so you can run gogitlocalstats without parameters.

Being able to pass an email as param makes it possible to scan repos for collaborators activity as well.

License: CC BY-SA 4.0

@flaviocopes
flaviocopes / check-substring-starts-with.go
Last active April 16, 2023 03:02
Go: check if a string starts with a substring #golang
View check-substring-starts-with.go
package main
import (
"strings"
)
func main() {
strings.HasPrefix("foobar", "foo") // true
}
@flaviocopes
flaviocopes / go-sort-map.go
Last active November 9, 2022 22:17
Go: sort a Map by key #golang
View go-sort-map.go
import "sort"
ages := map[string]int{
"a": 1,
"c": 3,
"d": 4,
"b": 2,
}
names := make([]string, 0, len(ages))
@flaviocopes
flaviocopes / check-substring-ends-with.go
Last active November 15, 2021 09:34
Go: check if a string ends with a substring #golang
View check-substring-ends-with.go
package main
import (
"strings"
)
func main() {
strings.HasSuffix("foobar", "bar") // true
}
View client.js
const ws = new WebSocket('ws://localhost:8080')
ws.onopen = () => {
console.log('Connected to the signaling server')
}
ws.onerror = err => {
console.error(err)
}
@flaviocopes
flaviocopes / intro.md
Last active December 23, 2019 06:42 — forked from derhuerst/intro.md
Installing Git on Linux, Mac OS X and Windows https://www.writesoftware.org/topic/git
View intro.md
@flaviocopes
flaviocopes / netlify.toml
Created July 19, 2018 06:23
Netlify configuration file for Hugo
View netlify.toml
[build]
publish = "public"
command = "hugo"
[context.production.environment]
HUGO_VERSION = "0.43"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.split1]
@flaviocopes
flaviocopes / receiver.js
Created November 23, 2018 11:08
PeerJS photo sharing example - receiver
View receiver.js
document.addEventListener('DOMContentLoaded', event => {
const peer = new Peer('receiver', {
host: 'localhost',
port: 9000,
path: '/'
})
peer.on('connection', conn => {
conn.on('data', data => {
if (data.filetype.includes('image')) {
@flaviocopes
flaviocopes / sender.js
Created November 23, 2018 11:08
PeerJS photo sharing example - sender
View sender.js
document.addEventListener('DOMContentLoaded', event => {
const peer = new Peer('sender', { host: 'localhost', port: 9000, path: '/' })
const conn = peer.connect('receiver')
document.querySelector('input').onchange = function(event) {
const file = event.target.files[0]
const blob = new Blob(event.target.files, { type: file.type })
conn.send({
View email.js
function (user, context, callback) {
if (context.clientName !== 'YOURAPPNAME') {
return callback(null, user, context);
}
var whitelist = ['info@example.com', 'owner@example.org']; //authorized emails
var userHasAccess = whitelist.some(
function (email) {
return user.email.toLowerCase() === email;
});