Skip to content

Instantly share code, notes, and snippets.

View ericho's full-sized avatar

Erich Cordoba ericho

View GitHub Profile
package main
import (
"fmt"
"image"
"image/color"
// This is an implicit import to register jpeg decoding.
"image/png"
"os"
)
@ericho
ericho / stx-mirrorless-report.md
Last active July 27, 2018 22:58
An attempt to build StarlingX in a mirrorless environment.

StarlingX building without rpm mirror

As you may already know, maintaining the mirror is a painful task. Everytime a new package changes release number (not even a version number) we need to update the mirror. There's a lot of work here and we are looking for solutions in different places.

Thinking in this problem I was wondering on how other distributions build their packages and on what are the requirements they request to the developers to have a complete build. I remove from my list the big ones, mostly because to me everything looks so complex that I get lost. So, I started to look for "small" linux distributions, more specific on Fedora and CentOS derivatives. By this way I found the Korora Project.

Looking into their repositories I found that they use mock with the difference that they don't require to download a mirror to get a build. If you see [these files] you'll see mock configuration files for several Fedora versions. So I

#[macro_use]
extern crate error_chain;
extern crate walkdir;
extern crate ring;
extern crate num_cpus;
extern crate threadpool;
@ericho
ericho / tp.rs
Created September 4, 2017 13:39
Example of threapool usage
#[macro_use]
extern crate error_chain;
extern crate walkdir;
extern crate ring;
extern crate num_cpus;
extern crate threadpool;
// error_chain! {
// foreign_links {
// Io(std::io::Error);
@ericho
ericho / sensys-docker
Created July 4, 2017 13:29
Sensys docker
FROM intelctrlsys/sensys-bld-centos7.3
RUN groupadd -g 1000 user && \
adduser -d /home/user -m -g user -u 1000 user
USER user
ENV HOME /home/user
ENV TERM xterm-256color
WORKDIR $HOME
@ericho
ericho / test.rs
Created May 2, 2017 04:33
Rust example
extern crate libc;
use std::ffi::CStr;
#[no_mangle]
pub extern fn testing(argc: i64, argv: *const *const libc::c_char) {
let l = unsafe { array_len(argv) };
println!("argc {}", argc);
println!("len {}", l);
let v = unsafe { array_to_vec(argv, l) };
extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use std::vec;
// Implement a bubble sort algorithm
// http://en.wikipedia.org/wiki/Bubble_sort
fn bubble_sort(vector: &mut Vec<i32>) {
@ericho
ericho / telegram.go
Created October 27, 2016 04:56
Sample telegram bot
package main
import (
"log"
"gopkg.in/telegram-bot-api.v4"
"fmt"
"database/sql"
_ "github.com/lib/pq"
)
diff --git a/src/or/config.c b/src/or/config.c
index 754b0af..1487b57 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2387,7 +2387,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
addr_string = tor_dup_ip(addr);
if (tor_addr_is_internal(&myaddr, 0)) {
/* make sure we're ok with publishing an internal IP */
- if (!options->DirAuthorities && !options->AlternateDirAuthority) {
+ if (is_default_dir_authorities(options)) {
@ericho
ericho / basic_module.c
Created August 24, 2015 19:20
A basic kernel module
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
int load_module(void)
{
printk(KERN_DEBUG "Hello world!\n");
return 0;
}