Skip to content

Instantly share code, notes, and snippets.

View StefansArya's full-sized avatar
🎍
Sorry I usually focus on GitLab repo

StefansArya StefansArya

🎍
Sorry I usually focus on GitLab repo
View GitHub Profile
@farhadi
farhadi / rc4.js
Created March 24, 2012 17:09
RC4 encryption in javascript and php
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
@hoandang
hoandang / apache-conf.md
Last active April 1, 2024 06:46
Sample vhost configuration

Sample apache vhost configuration

Udate /etc/hosts or c:\windows\system32\drivers\etc\hosts file so that the new servername is mapped to 127.0.0.1

Apache config file changes document root

    DocumentRoot "/Users/hoan/www"
<Directory "/Users/hoan/www">
    #

Possible values for the Options directive are "None", "All",

@TrevorJTClarke
TrevorJTClarke / MediaFormat
Last active July 24, 2023 08:25
MediaFormat - A regex system for finding the media ID for each type of popular social site. Can identify YouTube, Vimeo, Spotify, and Soundcloud.
/**
* MediaFormat
* format and return only needed pieces of media from their public sources
* Author: Trevor Clarke
*/
function MediaFormat (){
// http://www.youtube.com/embed/m5yCOSHeYn4
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/;
// http://vimeo.com/3116167, https://player.vimeo.com/video/50489180, http://vimeo.com/channels/3116167, http://vimeo.com/channels/staffpicks/113544877
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/;
@justmoon
justmoon / custom-error.js
Last active April 22, 2024 17:19 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@hacksalot
hacksalot / gist:72517b9b1c145116e89e
Created March 17, 2015 02:01
Delete GitHub wiki revisions
# Delete prior revisions from a GitHub wiki so that only the most-recent
# version of the content is available.
# Clone the wiki.
git clone https://github.com/[user]/[repo].wiki.git
# Remove the .git folder.
rm -rf .git
# Reconstruct the local repo with only latest content
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@omaraboumrad
omaraboumrad / wiki.md
Last active January 6, 2024 17:08
How to contribute to a GitHub Project's Wiki

Setup

Assuming project is SOME/PROJECT And you are FOO

You will need to do the following one time only:

@yujuiting
yujuiting / dynamic-load-uasset.cpp
Last active January 4, 2024 07:20
Unreal Engine 4: Dynamic load uasset
/*
load uasset from file path.
*/
FString filepath("/Game/an_animation_file"); // without extension, path start with `/Game`, `/Game` refer-> `Content` folder in real.
FStringAssetReference asset_stream_ref(filepath);
TAssetPtr<UAnimationAsset> animation_asset(asset_stream_ref);
UAnimationAsset* animation = animation_asset.LoadSynchronous();
bool isValid = animation_asset.IsValid();
bool isNull = animation_asset.IsNull();
bool isPending = animation_asset.IsPending();
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active April 21, 2024 12:50
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@iONinja
iONinja / uws.cpp
Last active April 18, 2020 04:53
An example of using µWebSockets in a C++ server
#include <uWS/uWS.h>
#include <iostream>
unsigned long getTime();
int main(int argc, char *argv[]) {
uWS::Hub h;
h.onMessage([](uWS::WebSocket<uWS::SERVER> *ws, char *data, size_t length, uWS::OpCode opCode) {