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
| -- Unfollow all shows in Podcasts.app | |
| -- | |
| -- Verified against the live UI (macOS 26 / Darwin 25.5.0) using System Events | |
| -- accessibility scripting. Podcasts.app exposes almost no standard container | |
| -- roles (no scroll area/table/outline) -- everything is nested AXGroups, so | |
| -- this walks the tree manually via `UI elements of X` rather than relying on | |
| -- System Events' recursive `every <class> of <container>` (which does not | |
| -- reliably descend through this app's structure). | |
| -- | |
| -- HOW TO RUN: osascript unfollow_all_podcasts.applescript |
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
| for line in 0...32 { | |
| println("".join((0...78).map { (col: Int) -> String in | |
| var x = 0.0, y = x, i = 0 | |
| do { | |
| x = x * x - y * y + Double(col) / 20.0 - 2.3 | |
| y = 2 * x * y + Double(line) / 10.0 - 1.5 | |
| i++ | |
| } while (x * x + y * y) < 4 && i < 78 | |
| return "\(UnicodeScalar(0x1f35b + 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
| ruby -e "32.times{|l|puts (0..78).map{|n|x=y=i=0;(x,y,i=x*x-y*y+n/38.0-1.5,2*x*y+l/14.0-1,i+1)until(x*x+y*y>4||i>78);(32+i).chr}*''}" |
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
| // Stringify using the replacer | |
| // const jsonBigInteger = JSON.stringify(bigInteger, bigIntReplacer); | |
| // Parse from JSON | |
| // const fromJsonBigInteger = JSON.parse(jsonBigInteger, bigIntReviver); | |
| export function bigIntReplacer(key: string, value: any): any { | |
| if (typeof value === "bigint") { | |
| return value.toString() + "n"; | |
| } | |
| return value; |
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
| # Naive implementation for finding the superpermutation of n symbols | |
| # https://en.wikipedia.org/wiki/Superpermutation | |
| n = 4 | |
| permutations = (1..n).to_a.permutation.map{|a| a.join} | |
| s = permutations.first | |
| permutations.shift | |
| while (permutations.length > 0) | |
| idx = nil |
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
| func standardDeviation(arr : [Double]) -> Double | |
| { | |
| let length = Double(arr.count) | |
| let avg = arr.reduce(0, {$0 + $1}) / length | |
| let sumOfSquaredAvgDiff = arr.map { pow($0 - avg, 2.0)}.reduce(0, {$0 + $1}) | |
| return sqrt(sumOfSquaredAvgDiff / length) | |
| } | |
| let responseTimes = [ 18.0, 21.0, 41.0, 42.0, 48.0, 50.0, 55.0, 90.0 ] |
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
| interface Test { | |
| done: boolean, | |
| name: string, | |
| } | |
| function fn(input: Test) { | |
| console.log(input.name) | |
| } | |
| let param1 : Test = {"done": true, "name": "Billie"} |
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
| The 10 longest user-agent strings from my access log. | |
| All of the are from Internet Explorer and the longest is 370 characters. This is silly! | |
| Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS129735; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; WWTClient2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.2; InfoPath.3; .NET4.0C; .NET4.0E) | |
| Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS125042; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; BO1IE8_v1;ENUS) | |
| Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YPC 3.2.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; msn OptimizedIE8;ENGB) | |
| Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5. |
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
| package com.example; | |
| import java.text.DateFormat; | |
| import java.text.ParseException; | |
| import java.text.SimpleDateFormat; | |
| import java.util.regex.*; | |
| public class Main { | |
| final static String DATE_FORMAT = "yyMMdd"; |
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
| JSON strings can contain {}. | |
| test_data = ["{dsfgsdf}", "{asdf}, {sdfsdf}", "{{dfgd}, {sadf}}", "sdfd}{", "{asdfsad}, {sdfs}}", "{{asdf},{sdfsdf}", '{"test{{{"}, {"{{{fest"}'] | |
| test_data.each { |s| | |
| instring = false; | |
| res = s.split(//).reduce(0) { |sum, c| | |
| break sum if sum < 0 | |
| instring = !instring if c == '"' | |
| if !instring |
NewerOlder