Skip to content

Instantly share code, notes, and snippets.

@cn007b
cn007b / websockets.php
Last active June 20, 2023 23:17
Super simple PHP WebSocket example - websockets.php
<?php
$address = '0.0.0.0';
$port = 12345;
// Create WebSocket.
$server = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($server, SOL_SOCKET, SO_REUSEADDR, 1);
socket_bind($server, $address, $port);
socket_listen($server);
@Hikingyo
Hikingyo / admin.sql
Last active April 14, 2024 06:42
create admin user with all privileges on mysql/mariadb
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
## remote connection - not secure
CREATE USER 'admin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
// main.cpp
// RSA
//
// Created by Sergiy on 06.06.17.
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
#include <stdio.h>
@Xaekai
Xaekai / ipc.example.js
Created July 11, 2016 18:12
Example of Interprocess communication in Node.js through a UNIX domain socket
/*
**
** Example of Interprocess communication in Node.js through a UNIX domain socket
**
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
**
*/
@RichardBronosky
RichardBronosky / pep8_cheatsheet.py
Created December 27, 2015 06:25
PEP-8 cheatsheet
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""This module's docstring summary line.
This is a multi-line docstring. Paragraphs are separated with blank lines.
Lines conform to 79-column limit.
Module and packages names should be short, lower_case_with_underscores.
Notice that this in not PEP8-cheatsheet.py
@redhog
redhog / Results
Last active May 26, 2022 17:49
GL.bufferData and GL.drawArrays performance test
Data size: 1000 000 points times 2 coords + 3 color values:
Load time for 1 arrays of 1000000 points = 39.8480000148993
Load time for 10 arrays of 100000 points = 57.4979999801144
Load time for 100 arrays of 10000 points = 53.67699998896569
Load time for 1000 arrays of 1000 points = 184.61100000422448
Load time for 10000 arrays of 100 points = 1469.6359999943525
Draw time for 1 arrays of 1000000 points = 0.15499998698942363
Draw time for 10 arrays of 100000 points = 0.3859999997075647
@candycode
candycode / image-arraybuffer.js
Created March 7, 2014 15:24
Create a jpg image from ArrayBuffer data
// Simulate a call to Dropbox or other service that can
// return an image as an ArrayBuffer.
var xhr = new XMLHttpRequest();
// Use JSFiddle logo as a sample image to avoid complicating
// this example with cross-domain issues.
xhr.open( "GET", "http://fiddle.jshell.net/img/logo.png", true );
// Ask for the result as an ArrayBuffer.
xhr.responseType = "arraybuffer";
@ashwin
ashwin / OpenTKExample.cs
Created June 7, 2013 04:20
An example C# program that uses OpenTK. Displays a colored triangle.
// C# example program to demonstrate OpenTK
//
// Steps:
// 1. Create an empty C# console application project in Visual Studio
// 2. Place OpenTK.dll in the directory of the C# source file
// 3. Add System.Drawing and OpenTK as References to the project
// 4. Paste this source code into the C# source file
// 5. Run. You should see a colored triangle. Press ESC to quit.
//
// Copyright (c) 2013 Ashwin Nanjappa
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 1, 2024 03:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname