Skip to content

Instantly share code, notes, and snippets.

View ernestas-poskus's full-sized avatar
💭
Lengthy disk encryption password eliminates keystroke errors

Ernestas Poskus ernestas-poskus

💭
Lengthy disk encryption password eliminates keystroke errors
View GitHub Profile
@ernestas-poskus
ernestas-poskus / gist:31fe6e42a34795b6d6bd
Created November 30, 2014 17:09
PID of running process
package main
import (
"fmt"
"os"
)
func main() {
os.Create("a.txt")
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@ernestas-poskus
ernestas-poskus / Image sorter for Dropbox
Created December 21, 2014 20:12
Image sorter for Dropbox
# Image sorter for Dropbox
require 'fileutils'
path = ARGV[1] || '.'
Dir.entries(path).each do |file|
m = file.scan(/^(\d{4})-(\d{2})-(\d{2}).+\.(jpg|jpeg|png|gif|mp4)/).flatten
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@ernestas-poskus
ernestas-poskus / gist:db3880e4f9d1146cf4ca
Created March 9, 2015 14:28
Go pointer overloading
package main
import "fmt"
// & (overloaded) - bitwise, address of operator, memory address
// * (indirection, dereference, type modifier) - access to value pointed by the variable
func main() {
var pi *int
z := 37 // z is of type int
@ernestas-poskus
ernestas-poskus / .agignore
Last active August 29, 2015 14:17
Ignore for Ag
/log/
/logs/
/images/
/javascripts/
/stylesheets/
/tmp/
/vendor/
/db/migrate/
Gemfile.lock

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter