Skip to content

Instantly share code, notes, and snippets.

View defrindr's full-sized avatar
👋
Hi there

Defri Indra Mahardika defrindr

👋
Hi there
View GitHub Profile
@jannson
jannson / output.txt
Last active February 23, 2021 10:09
The simple Reed Solomon example: http://ju.outofmemory.cn/entry/87811
origin d:
[5 7 6 2 4]
b:
[[ 1. 0. 0. 0. 0.]
[ 0. 1. 0. 0. 0.]
[ 0. 0. 1. 0. 0.]
[ 0. 0. 0. 1. 0.]
[ 0. 0. 0. 0. 1.]
[ 1. 1. 1. 1. 1.]
[ 1. 2. 3. 4. 5.]
@mylk
mylk / selenium.service
Created August 16, 2016 14:17
Selenium standalone server systemd script
# /etc/systemd/system/selenium.service
# assumes selenium server and chromedriver exist in the following paths:
# /var/selenium/selenium-server-standalone-2.45.0.jar
# /var/selenium/chromedriver
[Unit]
Description=Selenium Standalone Server
Requires=xvfb.service
After=xvfb.service
@aborruso
aborruso / updatefile.sh
Last active May 3, 2024 09:44
How to update a file in github via cURL
#!/bin/bash
cartella="/var/myfolder"
# update the file
curl -i -X PUT -H 'Authorization: token 4d013330xxxxxxxxxxxxxx' -d "{\"path\": \"mattei.csv\", \
\"message\": \"update\", \"content\": \"$(openssl base64 -A -in $cartella/mattei.csv)\", \"branch\": \"master\",\
\"sha\": $(curl -X GET https://api.github.com/repos/username/repo/contents/mattei.csv | jq .sha)}" \
https://api.github.com/repos/username/repo/contents/mattei.csv
@littlefuntik
littlefuntik / ActiveController.php
Created January 4, 2016 17:04
Yii2 rest Serializer example
<?php
namespace app\rest;
use yii\filters\AccessControl;
use yii\filters\auth\CompositeAuth;
use app\components\HeaderParamAuth;
/**
* Description of ActiveController
@r3verser
r3verser / AccessBehavior.php
Last active December 7, 2022 08:22
Yii2 Redirects all users to login (or any) page if not logged in, but allow access to some pages (like signup, password recovery etc.)
<?php
/*
* In configuration file
* ...
* 'as AccessBehavior' => [
* 'class' => 'app\components\AccessBehavior',
* 'allowedRoutes' => [
* '/',
* ['/user/registration/register'],
@PurpleBooth
PurpleBooth / README-Template.md
Last active June 2, 2024 05:30
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@aenglander
aenglander / htaccess_router.php
Created April 2, 2015 17:50
PHP .htaccess router for built in web server
<?php
if (file_exists($_SERVER['SCRIPT_FILENAME'])) {
return false;
}
$_SERVER['DOCUMENT_ROOT'] = empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['PWD'] . '/www' : $_SERVER['DOCUMENT_ROOT'];
$htaccess = $_SERVER['DOCUMENT_ROOT'] . '/.htaccess';
$rewrites = array();
if (file_exists($htaccess)) {
$fp = fopen($htaccess, "r");
@talnetd
talnetd / crud.c
Created February 12, 2015 15:59
Simple CRUD in C to understand how one connect to DATABASE
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define MAX_DATA 512
#define MAX_ROWS 100
struct Address {
@cferdinandi
cferdinandi / foreach.js
Last active October 1, 2020 08:01
A simple forEach() implementation for Arrays, Objects and NodeLists. Forked from ForEach.js by Todd Motto. https://github.com/toddmotto/foreach
/**
* A simple forEach() implementation for Arrays, Objects and NodeLists
* @private
* @param {Array|Object|NodeList} collection Collection of items to iterate
* @param {Function} callback Callback function for each iteration
* @param {Array|Object|NodeList} scope Object/NodeList/Array that forEach is iterating over (aka `this`)
*/
var forEach = function (collection, callback, scope) {
if (Object.prototype.toString.call(collection) === '[object Object]') {
for (var prop in collection) {
@anorth
anorth / ZoomLayout.java
Created March 29, 2014 00:06
Pinch-zoomable Android frame layout
package au.id.alexn;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.FrameLayout;