Skip to content

Instantly share code, notes, and snippets.

@cereal-s
cereal-s / nasa.apod.php
Last active December 21, 2016 10:49
NASA APOD API example with Memcached
<?php
/**
* Example of the NASA APOD API with Memcached
*
* @see https://api.nasa.gov/api.html#apod
* @see http://php.net/manual/en/class.memcached.php
*
* Since it is working with the `DEMO_KEY` rate limits
* are very low, and can be see in the RESPONSE headers, e.g.:
@cereal-s
cereal-s / recursive_files.php
Created December 24, 2016 13:43
Recursive directory iterator to list all readable files.
<?php
$path = dirname(__DIR__);
$dir_iterator = new RecursiveDirectoryIterator($path
, FilesystemIterator::SKIP_DOTS);
$iterator = new RecursiveIteratorIterator($dir_iterator
, RecursiveIteratorIterator::LEAVES_ONLY
, RecursiveIteratorIterator::CATCH_GET_CHILD);
@cereal-s
cereal-s / acos.py
Last active January 19, 2017 00:19
Calculate the inverse cosine in degrees.
#!/usr/bin/env python3
'''
Calculate the inverse cosine to
get the angle of the focus plane
in relation with the photographed surface.
Where `adjacent`, `opposite` and `hypotenuse`
are the parts of a right-angled triangle
@cereal-s
cereal-s / fx.php
Last active January 26, 2017 13:45
Generate a fade to the transparent, into the right side of the given image. Done with a composite gradient.
<?php
/**
* Script usage:
*
* /script.php?fade_width=200&image_url=http://localhost/images/image.jpg
*
* @see http://imagemagick.org/Usage/compose/#copy
* @see http://imagemagick.org/Usage/compose/#dstout
*
@cereal-s
cereal-s / index.html
Created January 29, 2017 11:58
rjYgPe
<div>
Helloz
</div>
@cereal-s
cereal-s / gist:c4c07138aded7c6cf17bb4da5aa3c1cc
Created May 22, 2017 12:26
[BASH] Watch specific process
watch -n 2 'ps -opid,pri,%cpu,%mem,user,args -p `pgrep php`'
@cereal-s
cereal-s / index.html
Created September 7, 2017 09:32 — forked from karbassi/index.html
How to handle single and double click events separately in javascript.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Single and Double Click</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="the_div"></div>
<span>Double click the block</span>
<?php
/**
* Trait helps to allow for some limited overloading of
* methods in the class this is attached to.
*/
trait Overloader {
/**
* Where the magic happens
@cereal-s
cereal-s / 00. tutorial.md
Created October 2, 2017 17:02 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler

Keybase proof

I hereby claim:

  • I am cereal-s on github.
  • I am cereal_ (https://keybase.io/cereal_) on keybase.
  • I have a public key whose fingerprint is FD33 B0C7 6279 29DD C23F 8180 374E DDFF 4BE9 C8D4

To claim this, I am signing this object: