Skip to content

Instantly share code, notes, and snippets.

Avatar
🗼

Camilo Sampedro camilosampedro

🗼
View GitHub Profile
@robmathers
robmathers / groupBy.js
Created Oct 25, 2018
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
View groupBy.js
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];
View .vimrc
set nocompatible
filetype off
syntax on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'nvie/vim-flake8'
@sinmetal
sinmetal / export.go
Created Nov 27, 2017
Google Cloud Datastore Export Handler
View export.go
package datastorebackup
import (
"fmt"
"net/http"
"time"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"google.golang.org/appengine/user"
@ahmetb
ahmetb / gcrgc.sh
Last active Nov 23, 2020
Script to clean up Google Container Registry images pushed before a particular date
View gcrgc.sh
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@camilosampedro
camilosampedro / Install Aton prerequisites.sh
Last active Nov 7, 2016
Installs Java 8, Activator and MySQL on Ubuntu 16.04 LTS
View Install Aton prerequisites.sh
#!/bin/bash
# Variables
activator_version="1.3.12"
mysql_password="atonmysqldb"
# Install java
echo " => Installing Java 8"
echo " ==> Adding webupd8team/java repository"
sudo add-apt-repository ppa:webupd8team/java
echo " ==> Updating with the added repository"
View javascript-trim-svg-whitespace.js
function trimSvgWhitespace() {
// get all SVG objects in the DOM
var svgs = document.getElementsByTagName("svg");
// go through each one and add a viewbox that ensures all children are visible
for (var i=0, l=svgs.length; i<l; i++) {
var svg = svgs[i],
box = svg.getBBox(), // <- get the visual boundary required to view all children
@cpburnz
cpburnz / NVIDIA_GeForce_GTX_960M_with_Optimus_on_Arch_Linux.rst
Last active Jan 31, 2020
NVIDIA GeForce GTX 960M with Optimus on Arch Linux
View NVIDIA_GeForce_GTX_960M_with_Optimus_on_Arch_Linux.rst

Packages

  • bumblebee 3.2.1-10 (provides nvidia-libgl)
  • mesa 11.0.4-1
  • mesa-libgl 11.0.4-1
  • nvidia 355.11-4 (Nvidia driver)
  • primus 20150118-2 (Bumblebee bridge)
  • xf86-video-intel 1:2.99.917+478+gdf72bc5-2 (Intel driver)
@granturing
granturing / reactive_map.js
Last active Sep 20, 2019
Sample reactive Leaflet code for Zeppelin
View reactive_map.js
<!-- place this in an %angular paragraph -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.5/leaflet.css" />
<div id="map" style="height: 800px; width: 100%"></div>
<script type="text/javascript">
function initMap() {
var map = L.map('map').setView([30.00, -30.00], 3);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@rjz
rjz / handler.go
Last active Oct 1, 2019
Handle Github webhooks with golang
View handler.go
// Now available in package form at https://github.com/rjz/githubhook
package handler
// https://developer.github.com/webhooks/
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
View message with zenity.sh
sudo -u $USERNAME DISPLAY=:0.0 zenity --warning --text="$MESSAGE"
You can’t perform that action at this time.