Skip to content

Instantly share code, notes, and snippets.

@noateden
noateden / Ubuntu-x11.md
Last active July 27, 2018 02:06
Create a ubuntu x11 docker image, forward GUI to docker host

Create Docker file

mkdir ubuntu-x11
cd ubuntu-x11
cat > Dockerfile

FROM ubuntu:bionic
RUN apt update
RUN apt install -y x11-apps
CMD ["/usr/bin/xeyes"]

Build image

sudo docker build -t xeyes .

@noateden
noateden / index.htm
Created August 5, 2018 08:03
Get started with ReacJS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Getting started with ReactJS</title>
</head>
<body>
<-- Create a button -->
<div id="like_button_container"></div>
<-- Add ReactJS -->
@noateden
noateden / hello_reactjs.html
Last active August 5, 2018 08:56
Hello ReactJS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Getting started with ReactJS</title>
</head>
<body>
<div id="hello"></div>
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
@noateden
noateden / c_mysql.c
Last active August 14, 2018 08:29
c mysql example
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mysql.h>
int main(int argc, char **argv)
{
@noateden
noateden / solidityUtils.sol
Created August 30, 2018 04:32
solidity utilities
pragma solidity ^0.4.18;
contract Utils{
function addressToBytes(address x) internal pure returns (bytes) {
bytes memory buffer = new bytes(20);
for (uint i = 0; i < 20; i++)
buffer[i] = byte(uint8(uint(x) / (2**(8*(19 - i)))));
return buffer;
}
function uintToBytes(uint v) internal pure returns (bytes) {
@noateden
noateden / Instructions
Created September 4, 2018 10:05
Netlink example in C
make
gcc -o netlinkUser netlinkUser.c
sudo insmod netlinkKernel.ko
./netlinkUser
sudo rmmod netlinkKernel
make lean
@noateden
noateden / iptables.sh
Last active September 15, 2018 07:33
Example iptables rule script
logfile="/var/log/trustbox"
# Clear all rules
iptables -F
iptables -X
# LOG all connection
iptables -A INPUT -j LOG
iptables -A OUTPUT -j LOG
# ALLOW ssh port 63378
# Allowed ip define in file 'ip.txt'
for ip in `cat ip.txt`
@noateden
noateden / service.sh
Created October 3, 2018 09:11
Simple service on linux
#!/bin/bash
case "$1" in
start)
/path/to/hit.sh &
echo $!>/var/run/hit.pid
;;
stop)
kill `cat /var/run/hit.pid`
rm /var/run/hit.pid
@noateden
noateden / jinja2_file_less.py
Created February 26, 2019 07:05 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@noateden
noateden / jquery_ajax_example.js
Created June 4, 2019 04:10
Example http request using javascript + jquery on client side
var settings = {
"async": true,
"crossDomain": true,
"url": "/docker/create/netapi",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
},
"data": {