This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Intersections between different objects | |
| # This demo shows intersects function between | |
| # Polygons (Box and Circle) | |
| # Note that applying buffer in (m) after projection happened | |
| # | |
| # 1) Reproject WGS84 to Web Mercator which uses m in UnicodeTranslateError | |
| # 2) Call intersects | |
| from shapely.geometry import Point,Polygon | |
| import pyproj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pyart | |
| import numpy as np | |
| radar = pyart.io.read_nexrad_level3("data/SI.kokx/sn.last") | |
| for i in range(0,radar.nrays): | |
| row = radar.fields['reflectivity']['data'][i] | |
| #get index of unmask items | |
| idx=np.where(~row.mask) | |
| dbz = row[idx] | |
| lat = radar.gate_latitude['data'][i][idx] | |
| lng = radar.gate_longitude['data'][i][idx] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use by piping | |
| // cat input22.txt | ./MyScanner | |
| // This is very slow | |
| // let xy = (readLine()!).characters.split(" ").map{Int(String($0))!} | |
| import Foundation | |
| var str = "" | |
| while true { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: c - Algorithm to find all the exact divisors of a given integer - Stack Overflow : http://stackoverflow.com/questions/11699324/algorithm-to-find-all-the-exact-divisors-of-a-given-integer | |
| import Cocoa | |
| func printDivisors(x:Int){ | |
| let sqr = sqrt(Double(x)) | |
| for i in 2..<Int(sqr)+1 { | |
| if x % i == 0 { | |
| print(i) | |
| if i != (x/i) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // gcd - Eucrid Algorithm | |
| // https://en.wikipedia.org/wiki/Greatest_common_divisor#Using_Euclid.27s_algorithm | |
| func gcd(n1:Int, n2:Int) -> Int { | |
| let nMax = max(n1,n2) | |
| let nMin = min(n1,n2) | |
| let reminder = nMax % nMin | |
| if reminder == 0 { | |
| return nMin | |
| } | |
| return gcd(nMin,n2:reminder) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Ommitted ... | |
| public class MainActivity extends AppCompatActivity | |
| implements NavigationView.OnNavigationItemSelectedListener { | |
| SpeechRecognizer mSpeech = null; | |
| Intent mIntent; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using OfficeOpenXml; | |
| using System.IO; | |
| using System.Drawing; | |
| using OfficeOpenXml.Drawing; | |
| using System.Drawing; | |
| namespace EPOneSample { | |
| class MainClass { | |
| public static void Main (string[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let m = 1000000000 | |
| var arr = [[Int]]() | |
| arr.append([1]) | |
| func nChooseK(n:Int, k:Int) { | |
| var prev = arr.last! | |
| if arr.count > n { | |
| prev = arr[n] | |
| } | |
| else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.rabbitmq.client.ConnectionFactory; | |
| import com.rabbitmq.client.Connection; | |
| import com.rabbitmq.client.Channel; | |
| // See python code comment for username / password settings | |
| //javac -cp rabbitmq-client.jar Send.java | |
| //java -cp .:./rabbitmq-client.jar Send | |
| public class Send { | |
| private final static String QUEUE_NAME = "javahello"; | |
| public static void main(String[] argv) throws Exception { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import pika | |
| server = '192.168.64.2' | |
| credentials = pika.PlainCredentials(username='test', password='test') | |
| connection = pika.BlockingConnection(pika.ConnectionParameters(host=server,credentials=credentials)) | |
| channel = connection.channel() | |
| channel.queue_declare(queue='hello') | |
| def callback(ch, method, properties, body): |