Skip to content

Instantly share code, notes, and snippets.

import copy
def convert_for_transform(op1, op2):
new_op_1 = {}
new_op_2 = {}
for j in op1:
for i in j:
if i == "retain":
op1_index = j[i]
new_op_1['index'] = op1_index
@umarrudi
umarrudi / encoded-complexity.go
Created September 20, 2022 00:46
A simplified (not executable) Go websocket ActiveClients map value that prove a point about encoded-complexity.
// Make a map containing clients
ActiveClients = make(map[ClientConn]int)
type ClientConn struct {
websocket *websocket.Conn
clientIP string
}
client := ws.Request().RemoteAddr
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title> WebSockets </title>
<script>
try {
var sock = new WebSocket("ws://{{.}}/sock");
//sock.binaryType = 'blob'; // can set it to 'blob' or 'arraybuffer
@umarrudi
umarrudi / shttpsc.c
Created April 12, 2022 03:02
Simplest https client with C
// compile : $ gcc file.c -lssl -lcrypto
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/x509v3.h>
#include <string.h>
#include <stdio.h>
#define DEB printf("%d\n",__LINE__ );
SSL *get_ssl(BIO *bio) {
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
// unmark pthread_detach(), memory leak will be gone
void* process( void* data ) {
printf( "hello world\n" );
}
main() {
package main
import (
"fmt"
"encoding/json"
)
var b = []byte(`{
"Module": [
{
@umarrudi
umarrudi / update-golang.md
Created July 12, 2021 05:03 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
String ipString = String.format("%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff), (ip >> 16 & 0xff), (ip >> 24 & 0xff));
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
// Compile : $ clang add.c -lpthread -w -o add
// atau $ gcc add.c -lpthread -w -o add
// https://stackoverflow.com/questions/24947446/pthread-create-how-do-i-get-the-returned-value-from-the-passed-function
#define TOTAL_CPU 8
#define LOOP_MAX 800000000 // LOOP_MAX nilainya sebesar memory fisik yang tersedia, jika terlalu besar akan segfault
#define LOOP_THREAD LOOP_MAX/TOTAL_CPU