Skip to content

Instantly share code, notes, and snippets.

View LolloDev5123's full-sized avatar
☣️

LolloDev LolloDev5123

☣️
  • Indirecta
  • Italy
  • 20:32 (UTC +02:00)
View GitHub Profile
@TheLinx
TheLinx / printr.lua
Created June 10, 2010 22:57
lua printr
-- this goes in your LUA_PATH, which you can find out by running:
-- lua -e 'print(package.path:sub(22,package.path:sub(22):find("%?%.lua")+20))'
-- first, require("printr")
-- then, use the function printr()
-- this code is public domain
local stringFormat,stringRep,stringChar = string.format,string.rep,string.char
local tableInsert,tableConcat = table.insert,table.concat
local function serializevalue(v, d, n)
@Yonaba
Yonaba / rle.lua
Created June 29, 2011 16:10
Run-Length Encoding Algorithm
-- RLE Encryption Algorithm Implementation
-- Used for data compression
-- Assuming original file is 'test.txt'
local file = io.open("test.txt","rb")
local Ssize = file:seek("end")
file:seek("set",0)
--RLEncodes a single string
function encode(std,flag)
@silentbicycle
silentbicycle / gist:3176678
Created July 25, 2012 15:10
Generate appropriate input for testing run-length encoding
-- Generate a random array of bytes, with some redundancy (via sorting).
function gen_int_array(limit)
limit = limit or 10000
local ri = lunatest.random_int
local length = ri(1, limit)
local ints = {}
for i=1,length do
-- keep them small, to increase duplication
ints[i] = ri(0, 2^8 - 1)
end
@silentbicycle
silentbicycle / gist:3176689
Created July 25, 2012 15:12
run-length encoding
-- Use literal zero for escape before compression data
local esc = 0
-- Run-length-encode an array of ints.
function encode(ints)
local res, i, ct = {}, 1, 1 -- result, index, count
while i <= #ints do
local v = ints[i]
while ints[i+1] == v do
ct = ct + 1
@Elemecca
Elemecca / hex_dump.lua
Created August 28, 2013 03:37
Lua function which creates a hex dump of a binary string.
function hex_dump (str)
local len = string.len( str )
local dump = ""
local hex = ""
local asc = ""
for i = 1, len do
if 1 == i % 8 then
dump = dump .. hex .. asc .. "\n"
hex = string.format( "%04x: ", i - 1 )
@veproza
veproza / AGPS.md
Last active July 23, 2023 04:36
Getting u-blox MAX-7C GPS to work with Assisted A-GPS

Getting u-blox MAX-7C GPS to work with Assisted A-GPS

So you got your u-blox GPS and wired it up only to look at it struggling to get a valid fix? Under less than ideal conditions, it can take a better part of half an hour. That's because unlike your smartphone GPS, it doesn't have the luxury of having downloaded all the auxiliary navigation data (almanacs and the lot) out-of-band, via fast mobile connection. Instead it relies on the satellite's signal itself, which is being transmitted to you at meager 50 bits per second (I'm not missing "kilo" there, it's three orders of magnitude slower than your 2G GPRS connection).

Luckily, the u-blox receivers are fitted with what the company calls "AssistNow" capability and it does exactly the same thing your iPhone does - feeds the GPS with pre-downloaded almanacs, speeding up the acquisition process to mere seconds.

In principle, the process looks easy enough - we just need to download the data, and then push them to the receiver. Sadly, the AssistNow documentat

@Maxs1789
Maxs1789 / console.lua
Created August 14, 2015 20:33
Lua console coded in Lua.
-- Print a prompt an read an input line
local function getline(line)
if line ~= "" then
io.write(">> ")
return line .. "\n" .. io.read()
end
io.write("> ")
@Elmuti
Elmuti / ai.lua
Created October 23, 2015 13:55
ai.lua
--[[
From a high-level perspective, NPCs follow a fairly simple (and real-world logical) process for making decisions.
The easiest way to understand it is to examine the basic outline first, and then dig further into the necessary exceptions afterwards.
Each time an NPC thinks, it follows this routine:
- Perform Sensing -
NPC Sensing generates a list of entities that it can see,
and another list of NPC sounds that it can hear.
The NPC ignores entities and sounds that it doesn't care about.
@peterneubauer
peterneubauer / .block
Last active July 4, 2022 14:33
mapillary-js perspective photo + Esri Leaflet, map clicking support
license: CC-0
@jgamblin
jgamblin / gist:2441964a1266764ed71f3243f87bbeec
Created May 8, 2016 00:02
Install Raspi-Config and rpi-update on Kali.
sudo apt-get update
sudo apt-get install lua5.1 alsa-utils triggerhappy curl libcurl3
wget http://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20160322_all.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/rpi-update/rpi-update_20140705_all.deb
dpkg -i raspi-config_20160322_all.deb
dpkg -i rpi-update_20140705_all.deb