Just in case I need to do performance troubleshooting in Rails some day: [Archive.is] hey on Twitter: “@shelbyspees @honeycombio From a browser. Thinking is we had trouble even narrowing it down to a section of the site. Thinking if we could see that most of the load was in some_controller we could maybe dig in there. I don’t want to take up too much of your time, but how would a double request show up?” / Twitter
Archive for the ‘Ruby’ Category
In case I ever need rails performance troubleshooting: I feel like I should be able to ask @datadoghq “What’s the CPU load across all our Rails controllers”, but have no idea where to start with that.
Posted by jpluimers on 2021/12/08
Posted in Development, Ruby, Software Development | Leave a Comment »
Constructing Suffix Trees: Ukkonen’s algorithm – Wikipedia
Posted by jpluimers on 2021/10/12
For my link archive:
- [WayBack] string – Ukkonen’s suffix tree algorithm in plain English – Stack Overflow
- [WayBack] Ukkonen’s algorithm – Wikipedia
- [WayBack] Esko Ukkonen – Wikipedia
- [WayBack] Esko Ukkonen
- [WayBack] Visualization of Ukkonen’s Algorithm
- [WayBack] Google Code Archive – Long-term storage for Google Code Project Hosting.
- [WayBack] suffix_trees.rb · GitHub
- [WayBack] Implementation of Ukkonen’s algorithm to build a prefix tree in O(n) · GitHub
- [WayBack] C# Suffix tree implementation based on Ukkonen’s algorithm. Full explanation here: http://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english · GitHub
- [WayBack] Simple suffix tree implementation in JavaScript. Install chalk to run the script below, or strip it down and remove all the debug messages and test cases. · GitHub
I also need to check out [WayBack] Martin Farach-Colton – Wikipedia, as his algorithm is likely more optimised and more versatile.
–jeroen
Posted in .NET, Algorithms, C#, Development, JavaScript/ECMAScript, Ruby, Scripting, Software Development | Leave a Comment »
Some Markdown links on phrasing more difficult markdown for correct rendering
Posted by jpluimers on 2019/08/20
After blogging on Markdown notes in 2014, Markdown support has come a long way. It also means that the documents written in Markdown has become more complex, and that more tools can render it.
Given the vague aspects of many Markdown dialects, rendering can be troublesome (see my post Babelmark 2 online Markdown checker), so below are some links on some aspects I had trouble with getting right.
- [WayBack] How to nest code within a list using Markdown – Meta Stack Exchange: indent the code with at least 4 more spaces than the minus signs in the unordered list.
- Tables inside unordered lists: example at [Archive.is] Babelmark 2 – Compare markdown implementations: tables within unordered lists which shows you need to have
- blank lines above/below the table so more Markdown tools render them as table.
- two spaces after each table line, so Markdown tools not rendering them as table rows, will render them as separate lines.
- Be sure to run your Markdown through [WayBack] markdownlint demo for syntax checking
Demo for markdownlint, a Node.js style checker and lint tool for Markdown/CommonMark files.
Note that there are two markdown linters:
- Ruby based [WayBack] GitHub – markdownlint/markdownlint: Markdown lint tool
- JavaScript based [WayBack] GitHub – markdownlint/markdownlint: Markdown lint tool (which follows the ruby based one, see for instance [WayBack] MD046 – Code block style (Ruby implementation) · Issue #131 · DavidAnson/markdownlint · GitHub and [WayBack] Issues · DavidAnson/markdownlint · GitHub: ruby)
Sometimes, issues are present in one, but not in the other; see:
- [WayBack] MD025 in quoted sections · Issue #235 · markdownlint/markdownlint · GitHub
- [WayBack] MD023 in quoted sections that are part of a list · Issue #236 · markdownlint/markdownlint · GitHub
The command line interface to the Ruby version is easier to install than the JavaScript version as everything is in one gem: mdl, unlike the npm, where the cli is in markdown-cli and the library in markdownlint.
–jeroen
Related:
Posted in *nix, *nix-tools, Development, Lightweight markup language, MarkDown, pandoc document converter, Power User, Ruby, Software Development | Leave a Comment »
How not to structure your database-backed web applications: a study of performance bugs in the wild | the morning paper
Posted by jpluimers on 2018/09/25
This is about Ruby anti-patterns, which is a good step to start investigating the own anti-patterns you use in your own development environment:
[WayBack] How not to structure your database-backed web applications: a study of performance bugs in the wild | the morning paper
How not to structure your database-backed web applications: a study of performance bugs in the wild Yang et al., ICSE’18 This is a fascinating study of the problems people get into when using…
Via: [WayBack] How not to structure your database-backed web applications: a study of performance bugs in the wild… – Adrian Marius Popa – Google+
–jeroen
Posted in Design Patterns, Development, Ruby, Software Development | Leave a Comment »
I wish the Delphi language supported multi-line strings
Posted by jpluimers on 2018/06/21
Very often, I see people ask for how to embed multi-line strings in a Delphi source file.
The short answer is: you can’t.
The long answer is: you can’t and if you want you have to hack your way around.
The answer should be: just like any of these languages that do support multiline strings:
- Python
- embed them with triple single quotes or triple double quotes: [WayBack] 3. An Informal Introduction to Python — Python 3.6.1 documentation – strings
- JavasScript
- as of ECMAScript 6, you can use backticks: [WayBack] Template literals – JavaScript | MDN
- Ruby
- Via the Here Documents syntax: [Archive.is] File: literals.rdoc [Ruby 2.2.0] – Here Documents
- C#
- By prepending the opening double quote of a string with @: [Archive.is] Code: Generating Multiline String Literals (Visual C#)
Many languages support this through a feature called HEREDOC.
Now in Delphi and other languages like Java are building ugly workarounds like for instance this one: [WayBack] RAD Studio Tip: Using resource scripts to organize project dependencies. – Chapman World.
–jeroen
Posted in .NET, C#, Delphi, Development, JavaScript/ECMAScript, Python, Ruby, Scripting, Software Development | 17 Comments »
Let’s stop copying C / fuzzy notepad
Posted by jpluimers on 2017/12/07
Ah, C. The best lingua franca we have… because we have no other lingua francas. Linguae franca. Surgeons general? C is fairly old — 44 years, now! — and comes from a time when there were possibly more architectures than programming languages. It works well for what it is, and what it is is a relatively simple layer of indirection atop assembly. Alas, the popularity of C has led to a number of programming languages’ taking significant cues from its design, and parts of its design are… slightly questionable. I’ve gone through some common features that probably should’ve stayed in C and my justification for saying so. The features are listed in rough order from (I hope) least to most controversial. The idea is that C fans will give up when I call it “weakly typed” and not even get to the part where I rag on braces. Wait, crap, I gave it away.
Great re-read towards the end of the year: [WayBack] Let’s stop copying C / fuzzy notepad
Via: [WayBack] Old and busted: emacs vs vi. New and hot: Language war, everybody against everybody else. – Kristian Köhntopp – Google+
–jeroen
Posted in .NET, APL, Awk, bash, BASIC, C, C#, C++, COBOL, CoffeeScript, CommandLine, D, Delphi, Development, F#, Fortran, Go (golang), Java, Java Platform, JavaScript/ECMAScript, Pascal, Perl, PHP, PowerShell, PowerShell, Python, Ruby, Scala, Scripting, Software Development, TypeScript, VB.NET, VBScript | 3 Comments »
Installing ruby gems on Windows
Posted by jpluimers on 2017/11/06
Steps:
- Install the Ruby Installer from rubyinstaller.org/downloads
- Add the directory where Ruby got installed to the user PATH (using
"%windir%\System32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables) in my caseC:\Ruby23\binas I installed Ruby 2.3.1 - Install the CA certificates:
- Download https://curl.haxx.se/ca/cacert.pem to the Ruby directory (
C:\Ruby32)- Note this used to be at http://curl.haxx.se/ca/cacert.pem but serving that over http instead of https does not much sense when you want to secure your connections.
- Add the environment variable
SSL_CERT_FILEwith valueC:\Ruby23\cacert.pem(again using"%windir%\System32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables).
- Download https://curl.haxx.se/ca/cacert.pem to the Ruby directory (
If you forget step 3, then you get errors like this:
C:\Users\jeroenp>gem install gist
ERROR: Could not find a valid gem 'gist' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
C:\Users\jeroenp>gem update --system
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
–jeroen
References
Posted in Development, Ruby, Software Development | Leave a Comment »
“Network Graph of Programming Language Influence – White Background” Posters by ramiro | Redbubble
Posted by jpluimers on 2017/11/03
Via [WayBack] Graph of programming languages influence poster – nice gift idea for programmers… – This is why I Code – Google+:
A network graph with more than a thousand programming languages connected by influence relations. Highly influential languages like Lisp, Smalltalk, C, Java, Pascal, C++, Haskel or Python are shown as larger circles as compared to languages with little influence on others like PHP or Argh!. / The influence relation data was retrieved from Freebase in 2013. This design available on posters and other products. An awesome gift for programmers who are into digital art. • Also buy this artwork on wall prints, apparel, kids clothes, and more.
[WayBack] “Network Graph of Programming Language Influence – White Background” Posters by ramiro | Redbubble
I wonder how they drew the relations and why certain languages are in certain places.
--jeroen
Posted in C, C++, COBOL, Development, Haskell, Java, Java Platform, JavaScript/ECMAScript, LISP, Pascal, Perl, PHP, Python, Ruby, Scripting, Smalltalk, Software Development, Turbo Prolog | Leave a Comment »
Argumate — program languages “What if …”
Posted by jpluimers on 2017/11/02
Quoted in full because even 2.5 years later, it’s just too funny:
- Python: What if everything was a dict?
- Java: What if everything was an object?
- JavaScript: What if everything was a dict *and* an object?
- C: What if everything was a pointer?
- APL: What if everything was an array?
- Tcl: What if everything was a string?
- Prolog: What if everything was a term?
- LISP: What if everything was a pair?
- Scheme: What if everything was a function?
- Haskell: What if everything was a monad?
- Assembly: What if everything was a register?
- Coq: What if everything was a type/proposition?
- COBOL: WHAT IF EVERYTHING WAS UPPERCASE?
- C#: What if everything was like Java, but different?
- Ruby: What if everything was monkey patched?
- Pascal: BEGIN What if everything was structured? END
- C++: What if we added everything to the language?
- C++11: What if we forgot to stop adding stuff?
- Rust: What if garbage collection didn’t exist?
- Go: What if we tried designing C a second time?
- Perl: What if shell, sed, and awk were one language?
- Perl6: What if we took the joke too far?
- PHP: What if we wanted to make SQL injection easier?
- VB: What if we wanted to allow anyone to program?
- VB.NET: What if we wanted to stop them again?
- Forth: What if everything was a stack?
- ColorForth: What if the stack was green?
- PostScript: What if everything was printed at 600dpi?
- XSLT: What if everything was an XML element?
- Make: What if everything was a dependency?
- m4: What if everything was incomprehensibly quoted?
- Scala: What if Haskell ran on the JVM?
- Clojure: What if LISP ran on the JVM?
- Lua: What if game developers got tired of C++?
- Mathematica: What if Stephen Wolfram invented everything?
- Malbolge: What if there is no god?
–jeroen
Posted in .NET, APL, Assembly Language, BASIC, C, C#, C++, COBOL, Development, EPS/PostScript, Fun, Go (golang), Java, Java Platform, JavaScript/ECMAScript, LISP, Makefile, Pascal, Perl, PHP, Python, Quotes, Ruby, Rust, Scala, Scripting, Smalltalk, Software Development, T-Shirt quotes, TCL, Turbo Prolog, VB.NET, Visual BASIC, XML/XSD, XSLT | Leave a Comment »
What Does Ruby’s Array#shift do? – Stack Overflow
Posted by jpluimers on 2017/09/20
Once you learn that
shift/unshiftare likepush/popon the other end of the array, you can mentally drop the ‘f’ from the name of the methods to remember which one ‘dumps’ elements and which one ‘inserts’ them. :)
Source: What Does Ruby’s Array#shift do? – Stack Overflow [WayBack]
Via: Originally shared by This is why I Code
https://stackoverflow.com/questions/3718625/what-does-rubys-arrayshift-do
Posted in Development, Fun, Ruby, Software Development | Leave a Comment »





