Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Technoknol technoknol

🎯
Focusing
View GitHub Profile
@inferusvv
inferusvv / toggleListItem.js
Last active Oct 2, 2020
Toggle item in array with ramda
View toggleListItem.js
import { append, contains, curry, ifElse, without } from 'ramda';
const toggleListItem = curry((value, list) => ifElse(
contains(value),
without([value]),
append(value),
)(list));
// Example:
const data = ['a', 'b', 'c', 'd'];
View zip-excluding-specific-directories-and-files.md

Zip excluding specific directories

Exclude .git file and node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*

Exclude .git file and files in node_modules directory, but keep node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
@tonY1883
tonY1883 / ValidateYoutubeVideoId.js
Created Sep 14, 2017
A small trick to check if youtube video exist with its id.
View ValidateYoutubeVideoId.js
function validVideoId(id) {
var img = new Image();
img.src = "http://img.youtube.com/vi/" + id + "/mqdefault.jpg";
img.onload = function () {
checkThumbnail(this.width);
}
}
function checkThumbnail(width) {
//HACK a mq thumbnail has width of 320.
@jeffochoa
jeffochoa / 1.ProcessClass.php
Last active Sep 14, 2021
Understanding Laravel pipelines
View 1.ProcessClass.php
<?php
namespace App\Features;
use App\Features\FirstTask;
use App\Features\SecondTask;
use Illuminate\Pipeline\Pipeline;
// *Naming things is hard* ... So, this is a class called `ProcessClass` that `run()` some text ¯\_(ツ)_/¯
class ProcessClass
@mavieth
mavieth / install-php-7.sh
Created May 2, 2017
Upgrade from PHP 5.X.X to PHP 7 on an AWS EC2 Linux Server
View install-php-7.sh
#!/bin/bash
echo "==============================="
echo "Installing PHP 7"
echo "==============================="
sudo yum install php70
echo "==============================="
echo "Installing PHP 7 additional commonly used php packages"
echo "==============================="
@sadikaya
sadikaya / git-bash-in-webstorm.md
Last active Nov 24, 2021
git bash inside Webstorm terminal
View git-bash-in-webstorm.md

Go to File -> Settings -> Tools -> Terminal and change Shell path based on the the installed git version.

for 64bit:

"C:\Program Files\Git\bin\sh.exe" --login -i

for 32bit:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i
@alexsasharegan
alexsasharegan / .htaccess
Created Sep 7, 2016
Apache Config for React Router
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@rheinardkorf
rheinardkorf / Hooks.js
Last active Jan 11, 2022
Simple WordPress like hooks system for JavaScript.
View Hooks.js
/**
* @file A WordPress-like hook system for JavaScript.
*
* This file demonstrates a simple hook system for JavaScript based on the hook
* system in WordPress. The purpose of this is to make your code extensible and
* allowing other developers to hook into your code with their own callbacks.
*
* There are other ways to do this, but this will feel right at home for
* WordPress developers.
*
@ivankristianto
ivankristianto / resumeable-file-download.php
Created Dec 17, 2013
Resumeable File Download With PHP
View resumeable-file-download.php
function serve_file_resumable ($file, $contenttype = 'application/octet-stream') {
// Avoid sending unexpected errors to the client - we should be serving a file,
// we don't want to corrupt the data we send
@error_reporting(0);
// Make sure the files exists, otherwise we are wasting our time
if (!file_exists($file)) {
header("HTTP/1.1 404 Not Found");
exit;