Skip to content

Instantly share code, notes, and snippets.

@codebrainz
codebrainz / c99.l
Created June 14, 2012 23:49
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@danieltorscho
danieltorscho / on-merge-deploy-to-do.md
Last active May 7, 2024 06:28
GitHub Action deploy nodejs to DigitalOcean Droplet

Github deployment

Requirements:

  • DigitalOcean Droplet (Ubuntu 20.04+) should be created
  • Github repository

Prepare DO Droplet Server:

  • ssh root@DROPLET_IP
  • sudo vi /etc/ssh/sshd_config
  • change PasswordAuthentication from no to yes
@maheshgawali
maheshgawali / keepcleandb_test_runner.py
Last active May 7, 2024 06:21
custom django test runner to flush db after all tests are done, but retain schema
'''
This test runner flushes the test db after all tests are run, and retains the schema (all tables will be truncated)
You can safely run all tests using --keepdb (recommended) parameter where in it will only keep the schema , but not the actual data
This saves times in frequent test runs as the entire test db schema doesnt have to be recreated every time
note that this will still apply newer migrations (if any) from last known point when the tests were run
if you actually want to retain test data, then do not use this test runner
'''
@imba-tjd
imba-tjd / .Cloud.md
Last active May 7, 2024 06:20
☁️ 一些免费的云资源

IaaS指提供系统(可以自己选)或者储存空间之类的硬件,软件要自己手动装;PaaS提供语言环境和框架(可以自己选);SaaS只能使用开发好的软件(卖软件本身);BaaS一般类似于非关系数据库,但各家不通用,有时还有一些其它东西。

其他人的集合

@munificent
munificent / generate.c
Last active May 7, 2024 06:19
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@YDrall
YDrall / kmp.cpp
Created August 18, 2015 16:10
c++ implementation of kmp string matching algorithm.
#include<iostream>
#include<string>
using namespace std;
int *pre_kmp(string pattern)
{
int size = pattern.size();
int *pie=new int [size];
pie[0] = 0;
@mks-d
mks-d / bahrain_ah.csv
Last active May 7, 2024 06:12
Bahrain address hierarchy: 'Governorate', 'Place', 'Block'
Southern Aáli 746
Southern Aáli 748
Southern Al Door 965
Southern Algainah 961
Southern Al Hajyat 929
Southern Al Hajyat 931
Southern Al Hajyat 935
Southern Al Hajyat 939
Southern Al Hunaniya 901
Southern Al Hunaniya 903
@er-pkumar
er-pkumar / laravel-pint.md
Last active May 7, 2024 06:11
Laravel Pint is a tool built on top of PHP-CS-Fixer for PHP code that helps you style your code in a specific way, especially if you prefer a minimalist approach.

What?

Laravel Pint is a tool built on top of PHP-CS-Fixer for PHP code that helps you style your code in a specific way, especially if you prefer a minimalist approach. By default install by installing fresh laravel application, Pint does not require any configuration and will fix code style issues in your code by following the opinionated coding style of Laravel.

Why Pint?

  • Consistency: Pint enforces a consistent code style across your Laravel projects, making it easier for developers to read and understand each other's code.
@er-pkumar
er-pkumar / search_multiple_column.md
Last active May 7, 2024 06:11
Laravel way to search across multiple column in table
$searchString = $request->validated('keyword');
$user = User::whereAny(
    [
        'first_name',
        'last_name',
        'email'
    ],
 'ilike',