Skip to content

Instantly share code, notes, and snippets.

@leearmstrong
leearmstrong / README.md
Created October 27, 2023 11:33 — forked from sancar/README.md
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
func GenerateESRIASC(data *input) {
f, err := os.Create("/tmp/esri.asc")
if err != nil {
fmt.Println(err)
return
}
defer f.Close()
yBottom := (data.FirstRowStartLine - data.IntervalBetweenColumns*(float32(data.NumberOfRowsInField)-1.0))
@leearmstrong
leearmstrong / sample.csv
Created December 13, 2019 12:45
Sample flight path data
lat lon pos_update_time altitude heading speed vert_rate
51.477905 -0.356091 13/12/2019 12:43:10 1925 270 113 -384
51.477905 -0.353641 13/12/2019 12:43:07 1925 270 113 -576
51.477951 -0.349781 13/12/2019 12:43:04 2000 270 120 -768
51.477951 -0.347331 13/12/2019 12:43:00 2000 270 121 -896
51.477951 -0.344288 13/12/2019 12:42:57 2050 270 134 -896
51.477951 -0.341987 13/12/2019 12:42:54 2075 270 131 -512
51.477997 -0.338795 13/12/2019 12:42:51 2100 270 135 -896
51.477978 -0.335617 13/12/2019 12:42:48 2150 270 136 -832
51.477978 -0.333023 13/12/2019 12:42:45 2200 270 137 -832
package main
import (
"bytes"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"sync"
@leearmstrong
leearmstrong / syncmap.go
Created January 3, 2017 04:46 — forked from lateefj/syncmap.go
Simple Shared Map Example In Go With Timeouts
// Example on sharing a map with multiple goroutines
package main
import (
"errors"
"fmt"
"sync"
"time"
)
@leearmstrong
leearmstrong / simulator_populator_xcode7
Created July 1, 2016 06:57 — forked from cabeca/simulator_populator_xcode7
This script removes and recreates all simulators in Xcode 7.
#!/usr/bin/env ruby
require 'JSON'
device_types = JSON.parse `xcrun simctl list -j devicetypes`
runtimes = JSON.parse `xcrun simctl list -j runtimes`
devices = JSON.parse `xcrun simctl list -j devices`
devices['devices'].each do |runtime, runtime_devices|
runtime_devices.each do |device|
-- copied from: http://mogmet.blog20.fc2.com/blog-entry-55.html
select @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH as GLOBAL_BUFFER_SIZE, @@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE as THREAD_BUFFER_SIZE, @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE) * @@GLOBAL.MAX_CONNECTIONS AS TOTAL_MEMORY_SIZE, (@@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFF
@leearmstrong
leearmstrong / Add Screen Recorder Button.py
Created February 28, 2016 17:37 — forked from BenjyWiener/Add Screen Recorder Button.py
Screen recorder for Pythonista
# coding: utf-8
from objc_util import *
from UIKit import *
from Foundation import *
from ReplayKit import *
from console import alert
def main():
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g' | xargs -n1 wget -N g