Skip to content

Instantly share code, notes, and snippets.

@abhinavabcd
abhinavabcd / tools.scad
Created April 19, 2026 08:12
named positions in openscad library - By Codex 5.4
// ── tools.scad ───────────────────────────────────────────────────────────
// Row format: ["new_name", "start_from", 4x4_matrix]
// or ["new_name", 4x4_matrix] (parent defaults to "world")
//
// "world" (or any undefined name) resolves to identity — use it as root anchor
//
// API:
// pos_matrix("name") → 4×4 matrix from inherited $positions root
// goto("name", from=undef, transform=I) { } → place children at name's world pose
// `from` defaults to the enclosing goto() frame
class RingBuffer{
i = 0; /*head pointer*/
j = 0; /*tail*/
data = null;
buf_size = 0;
constructor(_size, ArrType){
if(Number.isInteger(_size)){
ArrType = ArrType || Array;
this.data = new ArrType(_size + 1);
/*single thread RingBuffer*/
template<typename T, int MAX_BUFFER_SIZE = 50> class RingBuffer{
public:
T data[MAX_BUFFER_SIZE];
int i = 0; /*tail pointer*/
int j = 0; /*head*/
RingBuffer(){};
@abhinavabcd
abhinavabcd / phone_number_utils.py
Created April 17, 2021 17:38
Phone number parser.
#I didn't find any proper phone number parsers, so wrote one.
import re
#from . import data_utils
PHONE_NUMBER_REGEX = re.compile("^\+?[0-9]+")
country_code_num_digits_map = {"93": [9], "358": [10], "355": [9], "213": [9], "1": [10], "374": [6], "297": [7], "61": [9], "672": [6], "43": [11], "994": [9], "973": [8], "880": [10], "375": [9], "32": [9], "501": [7], "229": [6, 7, 8, 9], "387": [8], "55": [11], "246": [7], "359": [9], "226": [8], "855": [9], "235": [8], "56": [9], "86": [11], "57": [10], "682": [5], "506": [8], "385": [9], "357": [8], "420": [9], "45": [8], "670": [8], "593": [9], "20": [10], "503": [7], "44": [10], "268": [8], "500": [5], "298": [5], "691": [7], "33": [9], "594": [9], "689": [6], "241": [7], "995": [9], "49": [10], "233": [9], "30": [10], "299": [6], "590": [12], "852": [8], "36": [9], "91": [10], "62": [10], "98": [10], "353": [9], "972": [9], "39": [10], "81": [11], "7": [10], "686": [5], "383": [8], "965": [8], "371": [8], "961": [8], "231": [8], "218": [10], "370": [8], "3
@abhinavabcd
abhinavabcd / gist:769e3e670a6e097ef85deb67306e812b
Created February 25, 2017 20:15
C++ send push notification GCM/FCM
#include <fcntl.h>
#include <sys/socket.h>
#include <pthread.h>
#include <map>
#include <vector>
#include <set>
#include <errno.h>
#include <ctime>
#include <signal.h>
#include <netinet/in.h>
@abhinavabcd
abhinavabcd / SimpleViewPager.java
Created September 2, 2016 18:16
SimpleViewPager , add childs just like linearlayout
package com.appsandlabs.allspark.widgets;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;