Skip to content

Instantly share code, notes, and snippets.

View darkworks's full-sized avatar
🏠
Working from home

darkworks

🏠
Working from home
View GitHub Profile
@darkworks
darkworks / tip.html
Created May 6, 2018 09:52
Center text #css #web
# CSS text-align Property
div.a {
text-align: center;
}
div.b {
text-align: left;
}
@darkworks
darkworks / color-conversion-algorithms.js
Last active June 21, 2018 07:02 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@darkworks
darkworks / angle-between-points.js
Last active July 14, 2018 09:29 — forked from conorbuck/angle-between-points.js
JavaScript: Find the angle between two points
// FInd Angle between 2 point ... 0 to 90
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
@darkworks
darkworks / vpn.md
Created October 4, 2018 07:56 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

(A Russian translation of this article can be found here, contributed by Timur Demin.)

Why not?

@darkworks
darkworks / random_strgenerator.php
Created October 12, 2018 18:13 — forked from irazasyed/random_strgenerator.php
PHP: Generate random string
/**
* Generate and return a random characters string
*
* Useful for generating passwords or hashes.
*
* The default string returned is 8 alphanumeric characters string.
*
* The type of string returned can be changed with the "type" parameter.
* Seven types are - by default - available: basic, alpha, alphanum, num, nozero, unique and md5.
*
@darkworks
darkworks / media-query.css
Created October 16, 2018 05:02 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@darkworks
darkworks / genius-programmer.md
Created October 16, 2018 11:07 — forked from joepie91/genius-programmer.md
The One Secret Trick To Becoming A Genius Programmer

The One Secret Trick To Becoming A Genius Programmer

Okay, the title of this post is a bit of a lie. There's no one secret trick to becoming a genius programmer - there are two, and they're more habits than tricks. Nevertheless, these kind of 'secret tricks' seem to resonate with people, so I went for this title anyway.

Every once in a while, a somewhat strange thing happens to me. I'll be helping somebody out on IRC - usually a beginner - answering a number of their questions in rapid succession, about a variety of topics. Then after a while, they call me a "genius" for being able to answer everything they're asking; either directly, or while talking about me to somebody else.

Now, I don't really agree with this "genius" characterization, and it can make me feel a bit awkward, but it shows that a lot of developers have a somewhat idealistic and nebulous notion of the "genius programmer" - the programmer that knows everything, who can do everything, who's never stumped by a problem, and of which ther

function Animation(canvasId, fps) {
this.canvas = document.getElementById(canvasId);
this.drawingContext = this.canvas.getContext('2d');
this.fps = fps;
this.drawing = {};
this.frame = 0;
this.start();
}
Animation.prototype.start = function() {
@darkworks
darkworks / MediaQueries.css
Created December 8, 2018 07:13
css media queries for mobiles and desktop #css
@media only screen and (min-width: 1240px)
#Wrapper, .with_aside .content_wrapper {
max-width: 1210px;
}
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
@darkworks
darkworks / ImageManipulator.php
Created February 21, 2019 16:56
Image manipulation class, provides cropping, resampling and canvas resize
<?php
class ImageManipulator
{
/**
* @var int
*/
protected $width;
/**
* @var int