Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ophir LOJKINE lovasoa

🎯
Focusing
View GitHub Profile
View id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZ4MWfrK3MrBbfj+xP72A5Up2JT5p6pT9fv1UmNs4WF ophir-x1
@lovasoa
lovasoa / read_logs.go
Created Nov 30, 2020
Read compressed docker logs without decompressing them all to disks simultaneously. (see https://github.com/moby/moby/issues/41678)
View read_logs.go
package main
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"io"
"log"
"os"
@lovasoa
lovasoa / read_gzip_lines.go
Last active Nov 17, 2020 — forked from cathalgarvey/jlgz_dump.go
How to Read Lines from GZIP-Compressed Files in Go
View read_gzip_lines.go
package main
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"log"
"os"
)
View dezoomify-cloudflare-worker.js
/**
* This is a cloudflare worker for dezoomify
*/
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
@lovasoa
lovasoa / fork_bomb.rs
Created Jul 17, 2020
A process that repeatedly executes itself
View fork_bomb.rs
use std::process::Command;
use std::env;
use std::process;
use std::time::SystemTime;
use crossbeam; // 0.7.3;
pub fn main() {
let myself = env::current_exe().expect("no current exe");
let n: u64 = env::args()
.enumerate()
@lovasoa
lovasoa / mandelbrot.sql
Last active Jun 12, 2020
Mandelbrot rendering implemented in SQL
View mandelbrot.sql
WITH RECURSIVE
-- First, we define the grid we are working on
xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<0.5),
yaxis(y) AS (VALUES(-1) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1),
-- Then we compute the iterations of the mandelbrot function
iterations(iter, cx, cy, x, y) AS ( -- one value per iteration step per point
SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis -- c = cx + i * cy
UNION ALL
SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy -- z(iter+1) = z(iter)^2 + c. x=Re(z(iter+1)), y=Im(z(iter+1))
FROM iterations
@lovasoa
lovasoa / fibonacci.sql
Last active Jun 12, 2020
Computing the fibonacci sequence in SQL (with SQLite)
View fibonacci.sql
-- Computing the fibonaccci sequence in SQL
-- Using a common table expression
-- see: https://www.sqlite.org/lang_with.html
with recursive fibonacci (n, current, next) as (
select 0, 0, 1 -- n=0, current=fibonacci(0)=0, next=fibonacci(1)=1
union all -- Using a recursive union between the fibonacci table and itself
select n+1 as n, next, next+current -- n=n+1, current=next, next+=current
from fibonacci
)
View collatz_20.rs
use std::collections::BinaryHeap;
use std::collections::HashSet;
use std::cmp::Reverse;
fn main() {
println!("strict digraph {{");
let mut v : BinaryHeap<(Reverse<u128>, u8)> = Default::default();
let mut visited : HashSet<u128> = Default::default();
@lovasoa
lovasoa / collatz.rs
Created May 29, 2020
3n+1 conjecture in generic rust
View collatz.rs
use num::{Integer};
use std::ops::{MulAssign, DivAssign, AddAssign};
struct Collatz<T>(T);
impl<T> Iterator for Collatz<T>
where T: Integer + MulAssign + DivAssign + AddAssign + Clone,
{
type Item = T;
fn next(&mut self) -> Option<T> {
@lovasoa
lovasoa / naoned.as
Last active Mar 28, 2020
Naoned viewer image URL computation
View naoned.as
public function on_complete_load_xml(param1:Event) : void
{
var _loc3_:* = undefined;
var _loc4_:* = undefined;
var _loc7_:* = undefined;
var _loc8_:* = undefined;
var _loc9_:* = undefined;
var _loc10_:MovieClip = null;
is_authorize_mainclip = true;
var _loc2_:XML = new XML(param1.target.data);