Skip to content

Instantly share code, notes, and snippets.

View Taymindis's full-sized avatar
🏠
Working from home

Taymindis Woon Taymindis

🏠
Working from home
View GitHub Profile
@alan-mushi
alan-mushi / json_parser.c
Last active April 2, 2025 07:28
Examples for the json-c tutorial.
/*
* A simple example of json string parsing with json-c.
*
* clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c
*/
#include <json.h>
#include <stdio.h>
int main() {
struct json_object *jobj;
@rafaeltuelho
rafaeltuelho / camel-jdbc-connection-ds-pooling.xml
Last active March 14, 2019 17:22
JBoss Fuse: JDBC Datasource with Connection Pooling with Apache commons-dbcp2
<!-- add this snippet to your XML/Blueprint -->
<!-- Oracle -->
<bean id="oracleDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="initialSize" value="${db.pool.min}" />
<property name="maxTotal" value="${db.pool.max}" />
<property name="maxIdle" value="${db.pool.min}" />
@ralavay
ralavay / vim-nginx-conf-highlight.sh
Last active November 5, 2024 02:16
Enable syntax highlight for Nginx conf file in Vim
#!/bin/bash
#
# Highligh Nginx config file in Vim
# Download syntax highlight
mkdir -p ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim
# Set location of Nginx config file
cat > ~/.vim/filetype.vim <<EOF
@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@rafaeltuelho
rafaeltuelho / camel-raw-oauth.java
Created January 18, 2017 12:47
camel snippet using oauth to get an auth token and use it to request a secured rest service
from("timer://scheduler?period=30s")
.log("get access token")
.to("direct:authService");
from("direct:authService").tracing()
.setHeader(Exchange.HTTP_PATH)
.simple("<auth service context>/oauth2/token")
.setHeader("CamelHttpMethod")
.simple("POST")
.setHeader("Content-Type")
@Taymindis
Taymindis / multithread_test_zone.c
Created September 15, 2017 01:56
MultiThreading read and write for Hazard Pointer Logic in C
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#define THREAD_RUN 100
typedef struct $
{
char s[50];
} concurrent_update;
@bmaupin
bmaupin / free-backend-hosting.md
Last active May 14, 2025 18:15
Free backend hosting
@petitviolet
petitviolet / nginx_deployment.yaml
Created March 11, 2018 11:04
sample Nginx configuration on Kubernetes using ConfigMap to configure nginx.
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
data:
nginx.conf: |
user nginx;
worker_processes 3;
error_log /var/log/nginx/error.log;
events {
@Taymindis
Taymindis / spdlog_stream_route_handler.cpp
Last active July 7, 2018 03:46
stream route handler with spdlog
#include <iostream>
#include <stream_rt_handler.h>
/*https://github.com/gabime/spdlog*/
#include "spdlog/spdlog.h"
/***Compile by ***/
/** cd build **/
/** g++ -DSPDLOG_FMT_PRINTF -std=c++11 ../sample_with_spdlog.cpp -lsrh -pthread **/
@shankarshastri
shankarshastri / LearnXInYMinProtocolBuffer.proto
Last active April 18, 2025 15:09
Self-Explanatory Protocol Buffer Lang Guide (CheatSheet)
/*
* Self-Explanatory Protocol Buffer Lang Guide
*/
/*
* Why Protocol Buffers?
* Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
* You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
* Protocol Buffers are Schema Of Messages. They are language agnostic.