Skip to content

Instantly share code, notes, and snippets.

View maretekent's full-sized avatar

kent marete maretekent

  • http://glosoftgroup.com
  • Nairobi Kenya
View GitHub Profile
@maretekent
maretekent / codeiginter-server-config.md
Created January 13, 2020 23:50 — forked from yidas/codeiginter-server-config.md
Codeigniter 3 server configuration for Nginx & Apache

Codeigniter 3 server configuration for Nginx & Apache

Web Server Site Configuration

Recommended Apache Configuration

Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should set DocumentRoot and ServerName fit to your environment:

@maretekent
maretekent / zip.sh
Created November 14, 2019 14:25
zip on the fly
INPUT=$1
TIMESTAMP=`date +%Y-%m-%d-%H-%M-%S`
ARCHIVE_NAME=${INPUT}-${TIMESTAMP}.zip
mkdir -p build
cd $LAMBDA
zip -r $ARCHIVE_NAME .
mv $ARCHIVE_NAME ../build/
cd ..
@maretekent
maretekent / CodeMonk#pg_backup.bat
Created February 20, 2019 09:57 — forked from CodMonk/CodeMonk#pg_backup.bat
Batch file to backup PostgreSQL DB
@echo off
goto comment
Author: Code Monk
Description: This file use to backup the database using PostgreSQL backup utility "pg_dump".
Backup parameters should be setup before executing this file
File Format flags :
c = Custom
t = Tar
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
CARGO_WEB_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest)
CARGO_WEB_VERSION=$(echo $CARGO_WEB_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/$CARGO_WEB_VERSION/cargo-web-x86_64-unknown-linux-gnu.gz"
echo "Downloading cargo-web from: $CARGO_WEB_URL"
@maretekent
maretekent / rust cargo aliases
Created December 19, 2018 18:48
rust cargo aliases
alias c="cargo"
alias ci="cargo init"
alias cib="cargo init --bin"
alias cn="cargo new"
alias cnb="cargo new --bin"
alias cc="cargo check"
alias cca="cargo check --all-targets"
alias cb="cargo build"
alias cbr="cargo build --release"
@maretekent
maretekent / gist:cd39b3da62488fbe05e5ccf6d550d1e9
Created September 15, 2018 08:24 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@maretekent
maretekent / struct_copy.rs
Last active September 13, 2018 13:48
Copying elements of one struct to another
struct Color {
red: u8,
green: u8,
blue: u8
}
fn main() {
let mut link_color = Color {red: 0,green: 0,blue: 255};
link_color.blue = 238;
println!("Link Color = rgb({}, {}, {})", link_color.red, link_color.green, link_color.blue); //Link Color = rgb(0, 0, 238)
@maretekent
maretekent / vec_deque.rs
Created September 13, 2018 10:50
snippet to rotate the number
use std::collections::VecDeque;
fn main() {
let num = 1970;
let mut buf: VecDeque<_> = num.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect();;
for _ in 0..buf.len() {
println!("{:?}", buf);
let n = buf.pop_front().unwrap();
buf.push_back(n);
}
}
@maretekent
maretekent / Spin_vector.rs
Created September 12, 2018 14:14
Spin vector
use std::ops::Shr;
#[derive(PartialEq, Debug)]
struct SpinVector<T: Clone> {
vec: Vec<T>,
}
impl<T: Clone> Shr<usize> for SpinVector<T> {
type Output = Self;