Skip to content

Instantly share code, notes, and snippets.

@mmirolim
mmirolim / example.go
Created November 8, 2015 13:47 — forked from heatxsink/glog-example.go
An example of how to use golang/glog.
/*
glog-example
------------
background
---
You probably want to read the source code comments at the top of the glog.go file in
the golang/glog repository on github.com. Located here: https://github.com/golang/glog/blob/master/glog.go
setup
package main
import (
"bytes"
"encoding/gob"
"io/ioutil"
"log"
"os"
"time"
@mmirolim
mmirolim / predicting_customer_behav_1.R
Created January 29, 2016 07:44 — forked from mattbaggott/predicting_customer_behav_1.R
Uses the BTYD package and Pareto/NBD model to predict customer behavior in R Slides are at: http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1#
#
# PREDICTING LONG TERM CUSTOMER VALUE WITH BTYD PACKAGE
# Pareto/NBD (negative binomial distribution) modeling of
# repeat-buying behavior in a noncontractual setting
#
# Matthew Baggott, matt@baggott.net
#
# Accompanying slides at:
# http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1#
#
package main
import (
"fmt"
"math"
)
type VM struct {
Floats [1 << 8]float64
Code []Instr
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''Task
https://www.hackerrank.com/challenges/30-bitwise-and
Given set S={1,2,3,…,N}S={1,2,3,…,N}. Find two integers, AA and BB (where A<BA<B), from set SS such that the value of A&BA&B is
the maximum possible and also less than a given integer, KK. In this case, && represents the bitwise AND operator.
Input Format
@mmirolim
mmirolim / rune-reading.go
Created August 4, 2016 20:54
rune handling example
package main
import (
"fmt"
"unicode"
"unicode/utf8"
)
func isCombo(r rune) bool {
return unicode.Is(unicode.Mn, r) || unicode.Is(unicode.Me, r) || unicode.Is(unicode.Mc, r)
@mmirolim
mmirolim / tests-with-glog-verbosity.go
Created August 25, 2016 08:21
set glog verbosity during tests
var myV = flag.Int("myV", 23, "test")
func TestFlag(t *testing.T) {
flag.Lookup("v").Value.Set(fmt.Sprint(*myV))
println(*v, *myV)
}
// or
func init() {
if testing.Verbose() {
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Command caption reads an audio file and outputs the transcript for it.
package main
import (
"fmt"
"io"
@mmirolim
mmirolim / autovpn.py
Created October 6, 2016 12:03 — forked from domenkozar/autovpn.py
AutoVPN for NetworkManager
#!/usr/bin/env python
"""
Copyright 2011 Domen Kozar. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
#!/bin/bash +x
while [ "true" ]
do
VPNCON=$(nmcli con status | grep *MyVPNConnectionName* | cut -f1 -d " ")
if [[ $VPNCON != "*MyVPNConnectionName*" ]]; then
echo "Disconnected, trying to reconnect..."
(sleep 1s && nmcli con up uuid df648abc-d8f7-4ce4-bdd6-3e12cdf0f494)
else
echo "Already connected !"
fi