Skip to content

Instantly share code, notes, and snippets.

View varemenos's full-sized avatar

Adonis Kakoulidis varemenos

View GitHub Profile
@varemenos
varemenos / 1.objectCreation.js
Created May 15, 2013 15:45
JavaScript - The basics of Object Oriented Programming
// Class creation
function Vehicle(p) {
this.brand = p.brand || "";
this.model = p.model || "";
this.wheels = p.wheels || 0;
}
// Main class' methods
Vehicle.prototype.getBrand = function () {
return this.brand;
@varemenos
varemenos / oop.php
Created May 16, 2013 00:24
PHP - Basic OOP
<?
class entry{
private $id = -1; // required
private $title = ""; // required
private $author = -1; // required, author ID
private $excerpt = ""; // either turn title into excerpt or manually enter one
private $date = ""; // required
// #TODO
// post type interface?
@varemenos
varemenos / index.html
Created May 21, 2013 05:32
JavaScript - "Are you sure you want to leave this page"
<a href="http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one-help-me/9325742#9325742">Leave this page!</a>
@varemenos
varemenos / compare.js
Created May 25, 2013 06:48
JavaScript - Comparison results
var a = '5';
var b = new String('5');
console.log( typeof a, typeof b, a == b, a === b );
/* Output:
> string
> object
> true
@varemenos
varemenos / timer.js
Created June 7, 2013 16:53
JavaScript - Timer functionality
// from: http://stackoverflow.com/a/3969760/649239
function Timer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
@varemenos
varemenos / module.js
Last active December 21, 2015 13:09
JavaScript - Modularity
(function () {
'use strict';
// change "moduleName" to the name of the module you are making
var moduleName = {};
// do something
if (typeof module !== 'undefined' && module.exports) {
module.exports = moduleName;
} else {
@varemenos
varemenos / Microsoft.PowerShell_profile.ps1
Created August 23, 2013 05:04
A profile script that generates a prompt similar to this: AdonisK@home-pc: C:\Users\AdonisK$_
# Clear screen
cls
# Get user
$USER = $PWD.toString()
$USER = $USER.Remove(0, 9)
# Get hostname
$HOSTNAME = HOSTNAME.exe
@varemenos
varemenos / powerquake.ahk
Created August 27, 2013 05:24
PowerShell - QuakeStyle (now supports posh~git as well)
F12::
DetectHiddenWindows, on
If WinExist("posh~git") OR WinExist("Windows PowerShell")
{
If WinActive("posh~git") OR WinActive("Windows PowerShell")
{
WinHide
if(temptitle="")
WinActivate ahk_class Shell_TrayWnd
@varemenos
varemenos / checkCalc.js
Last active December 29, 2015 12:19
Check if calc() is supported by your browser
// returns true if your browser supports calc()
myapp.checkCalc = function (prefix = '') {
var el = document.createElement('div');
el.style.cssText = prefix + 'width: calc(1px);';
return !!el.style.length;
};
// returns true if your browser supports any version of calc(), prefixed or not
myapp.checkAllCalc = function (prefix = '') {
return myapp.checkCalc('-webkit-') || myapp.checkCalc('-moz-') || myapp.checkCalc();
@varemenos
varemenos / oh-my-zsh-plugins.zsh
Last active August 29, 2015 13:57
oh-my-zsh plugins
plugins=(gitfast last-working-dir ssh-agent bower nvm gem node npm rbenv themes grunt autoenv zsh-syntax-highlighting command-not-found)