Skip to content

Instantly share code, notes, and snippets.

View vedro-compota's full-sized avatar

vedro-compota vedro-compota

View GitHub Profile
@gaearon
gaearon / modern_js.md
Last active April 18, 2024 15:01
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@kevinweber
kevinweber / encodeSvg.js
Created October 31, 2016 05:36
Helper: Convert React component (SVG element) to base64 encoded URL. Useful for adding a background image.
import ReactDOMServer from 'react-dom/server';
export function encodeSvg(reactElement) {
return 'data:image/svg+xml,' + escape(ReactDOMServer.renderToStaticMarkup((reactElement)));
}
@faizalmansor
faizalmansor / ExampleController.php
Created March 8, 2016 03:00
Yii2 Access Control to make all actions in controller required login by default
<?php
namespace app\controllers;
use yii\filters\AccessControl;
use yii\web\Controller;
class ExampleController extends Controller
{
public function behaviors()
@drmalex07
drmalex07 / README-create-debian-startup-script.md
Last active September 29, 2023 11:42
An example of how to create a init.d script in Debian, using dependency booting. #debian #init.d #lsb-script #startup-script
@jwebcat
jwebcat / gist:5122366
Last active March 25, 2024 18:25 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@plasticbrain
plasticbrain / gist:3887245
Created October 14, 2012 04:00
PHP: mime types (array format)
<?php
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
'.aas' => 'application/x-authorware-seg',
'.abc' => 'text/vnd.abc',
'.acgi' => 'text/html',
@brasofilo
brasofilo / download.php
Created June 3, 2012 12:55
Force File Download with PHP
<?php
/*
* Foce File Download
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary
*
*/
// grab the requested file's name