Skip to content

Instantly share code, notes, and snippets.

View KarelWintersky's full-sized avatar

Karel Wintersky KarelWintersky

View GitHub Profile
@krypt-lynx
krypt-lynx / jff-csv.cs
Last active July 25, 2020 21:31
Comma Separated Values reader/writer
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace csv
{
static class CSV
{
@ozee31
ozee31 / array_unset.js
Last active June 18, 2020 11:20
Supprime des éléments d'un tableau
/**
* Remove all occurrences of a given value from an array
* @param {mixed} val : value to delete
*/
Array.prototype.unset = function(val){
var index;
while ( (index = this.indexOf(val)) !== -1 ) {
this.splice(index,1);
}
@ozee31
ozee31 / in_array.js
Created August 7, 2014 14:46
Indique si une valeur appartient à un tableau
/**
* Checks if a value exists in an array
* @param {mixed} needle : The searched value
* @param {array} haystack : The array
* @return {bool}
*/
var in_array = (function (needle, haystack) {
return ( haystack.indexOf(needle) !== -1 );
});
@silverslice
silverslice / DbMysql.php
Last active August 29, 2015 14:14
Mysql wrapper for legacy projects
<?php
/**
* Подключение к БД
*
* @param $host
* @param $user
* @param $pass
* @param $db
* @return bool|resource
*/
// by Erik Wrenholt
import java.util.*;
class Mandelbrot
{
static int BAILOUT = 16;
static int MAX_ITERATIONS = 1000;
private static int iterate(float x, float y)
{
@protrolium
protrolium / ffmpeg.md
Last active May 15, 2024 18:27
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@kissarat
kissarat / descend.sql
Created June 16, 2015 01:30
MySQL. Gets all descendants (children) for given ID of parent with depth parameter
DROP PROCEDURE IF EXISTS descend;
CREATE PROCEDURE descend(uid INT, depth INT) BEGIN
DROP TABLE IF EXISTS descendants;
DROP TABLE IF EXISTS children;
CREATE TEMPORARY TABLE descendants (
id int,
parent_id int,
level int
) ENGINE = MEMORY;
INSERT INTO descendants(id, level)
@irazasyed
irazasyed / weight-utility.php
Created January 8, 2016 09:21
PHP: Utility function for getting random values with weighting.
<?php
/**
* getRandomWeightedElement()
* Utility function for getting random values with weighting.
* Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50)
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
* The return value is the array key, A, B, or C in this case. Note that the values assigned
* do not have to be percentages. The values are simply relative to each other. If one value
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66%
* chance of being selected. Also note that weights should be integers.
@ssokolow
ssokolow / firefox_migration.rst
Last active February 26, 2024 04:35
Disaster Plans for Firefox XUL Sunset

Disaster Plans for Firefox XUL Sunset

Public URL

Github Gist

Status

Incomplete

Last Updated

2018-08-23 04:10 EDT

Threat Summary

@Pulimet
Pulimet / AdbCommands
Last active May 18, 2024 09:02
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader