Skip to content

Instantly share code, notes, and snippets.

Robin Percy rbnpercy

Block or report user

Report or block rbnpercy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View base64_test.cr
require "base64"
STR_SIZE = 131072
TRIES = 8192
str = "a" * STR_SIZE
str2 = Base64.strict_encode(str)
print "encode #{str[0..3]}... to #{str2[0..3]}...: "
View base64_test.nim
import base64, times, strutils, strformat
let STR_SIZE = 131072
let TRIES = 8192
let str = strutils.repeat('a', STR_SIZE)
var str2 = base64.encode(str)
stdout.write(fmt"encode {str[..3]}... to {str2[..3]}...: ")
var t = times.epochTime()
View json_test.cr
require "json"
text = File.read("1.json")
jobj = JSON.parse(text)
coordinates = jobj["coordinates"].as_a
len = coordinates.size
x = y = z = 0
coordinates.each do |coord|
x += coord["x"].as_f
View json_test.nim
import json
let jobj = parseFile("1.json")
let coordinates = jobj["coordinates"].elems
let len = float(coordinates.len)
var x = 0.0
var y = 0.0
var z = 0.0
View coordinate_syntax.json
{
"coordinates": [
{
"x": 0.10327081810860272,
"y": 0.03247172212368832,
"z": 0.8155255437507467,
"name": "scojbq 5965",
"opts": {
"1": [
1,
View generate_json.rb
require 'json'
x = []
1000000.times do
h = {
'x' => rand,
'y' => rand,
'z' => rand,
'name' => ('a'..'z').to_a.shuffle[0..5].join + ' ' + rand(10000).to_s,
View hi_built
$ crystal build --release src/sayhi_c.cr
$ ./sayhi_c
> Hi Status!
View sayhi_c.cr
require "./sayhi_c/*"
@[Link(ldflags: "#{__DIR__}/sayhi_c/sayhi.o")]
lib Say
fun hi(name : LibC::Char*) : Void
end
Say.hi("Status")
View sayhi.c
#include <stdio.h>
void hi(const char * name){
printf("Hi %s!\n", name);
}
View html_page.html
<!DOCTYPE html>
<html class='has-navbar-fixed-top' >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
</head>
<body class='has-navbar-fixed-top' >
<p >Hello</p>
<p >World</p>
You can’t perform that action at this time.