Skip to content

Instantly share code, notes, and snippets.

@adeelibr
adeelibr / Abort Controller In Axios
Last active April 20, 2024 00:50
Abort Controllers In Axios
import React, { Component } from 'react';
import axios from 'axios';
class Example extends Component {
signal = axios.CancelToken.source();
state = {
isLoading: false,
user: {},
}
@shernshiou
shernshiou / createtable.js
Created May 15, 2018 06:19
Knex createtable sqlite uuid
let uuidGenerationRaw = connection.client.config.client === 'sqlite3' ?
`(lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6))))` :
`uuid_generate_v4()`;
connection.schema.createTableIfNotExists('notification', (table) => {
table.uuid('id').primary().defaultTo(connection.raw(uuidGenerationRaw));
// ... rest of the columns
}),
@amark
amark / li.html
Last active April 30, 2023 05:25
<html><body>
<style>
html, body {
background: rgb(245, 245, 245);
margin: 0;
padding: 0;
}
div {
position: relative;
overflow: hidden;
@emilioriosvz
emilioriosvz / mongoose-connection.js
Created April 4, 2018 09:40
connect with mongoose using async/await
const mongoose = require('mongoose')
mongoose.Promise = Promise
mongoose.connection.on('connected', () => {
console.log('Connection Established')
})
mongoose.connection.on('reconnected', () => {
console.log('Connection Reestablished')
@deanhu2
deanhu2 / hello_triangle.cpp
Created March 11, 2018 17:32 — forked from vittorioromeo/hello_triangle.cpp
SDL2 + OpenGL ES 2.0 - "Hello triangle" example that works both on X11 and Emscripten
#include <exception>
#include <functional>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
@gfriloux
gfriloux / Cargo.toml
Created December 12, 2017 14:49
Streaming data
[package]
name = "chunked"
version = "0.1.0"
authors = ["Guillaume Friloux <[email protected]>"]
[dependencies]
rocket = "0.3.3"
rocket_codegen = "0.3.3"
rocket_contrib = "0.3.3"
@mbinna
mbinna / effective_modern_cmake.md
Last active April 25, 2025 22:01
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@santosh
santosh / senduseragent.py
Created November 2, 2017 07:12
Return back user agent in Flask. #Python
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def index():
user_agent = request.headers.get('User-Agent')
return '<p>Your browser is {}!</p>'.format(user_agent)
@app.route('/user/<name>')
def user(name):
@cyaoeu
cyaoeu / fbx_batchexport_anims.py
Created August 29, 2017 17:57
Blender script: batch export anims
import bpy
path = bpy.path.abspath('//') #path of .blend
objname = bpy.context.active_object.name #select rig
singleanim = True
if singleanim == True:
action = bpy.context.active_object.animation_data.action
@psqq
psqq / main.cpp
Last active September 15, 2024 04:07
Simple SDL_net example
#include <SDL.h>
#include <SDL_net.h>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
if (SDL_Init(0) == -1) {
printf("SDL_Init: %s\n", SDL_GetError());