Skip to content

Instantly share code, notes, and snippets.

View gaboratorium's full-sized avatar

gaboratorium gaboratorium

View GitHub Profile
@gaboratorium
gaboratorium / Default (Windows).sublime-keymap
Last active August 30, 2016 08:51
Sublime Text settings #sublime #settings
[
// Comment out current line
{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
// Start a comment
{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } },
// Open folder
{ "keys": ["ctrl+shift+o"], "command": "prompt_open_folder" },
// insert console.log()
{ "keys": ["super+shift+l"], "command": "insert_snippet", "args": { "contents": "console.log(${1:}$SELECTION);${0}" } },
// Create post template
@gaboratorium
gaboratorium / string_escape.php
Last active April 19, 2016 16:22
One way of escaping strings in mySQL requests
<?php
$firstanme = $_GET['firstname'];
$sql="INSERT INTO users(`firstname`) VALUES (:firstname)";
$stmt = $db->prepare($sql);
$stmt->bindValue(':placeholder, $firstname');
$stmt -> execute();
?>
@gaboratorium
gaboratorium / email_sending.php
Created April 19, 2016 16:21
Sending an e-mail with PHP
<?php
$headers =
'From: Expozers Team <[email protected]>' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
mail($mail,"Invite",$msg, $headers);
header('Location:?page=admin');
?>
@gaboratorium
gaboratorium / textscore.js
Created April 19, 2016 16:23
Track article reading progress with JavaScript
/*
stats list - parameter to analyze
- if is read
- how much time spent
- how much was read
- idle time (no scrolling + no mouse move + no typing)
- time spent with some element (article suggestions) in the viewport
is_read = scroll to the the end of the element observed and time_spent > 80%
*/
@gaboratorium
gaboratorium / ajax.js
Last active June 3, 2016 07:13
Basic #ajax call
// creating the object
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject() {
var xmlHttp;
//all modern browsers
if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
//if IE 6 or below
else if (window.ActiveXObject("Microsoft.XMLHTTP"))
@gaboratorium
gaboratorium / bem.scss
Last active June 3, 2016 07:12
BEM naming convention in CSS #bem #css #sass
// Search UI Block
.search {
// Elements
> .search__field {
/* ... */
}
> .search__btn {
/* ... */
}
@gaboratorium
gaboratorium / gist:eed2cf06cced2b527c104545dccac111
Last active June 3, 2016 07:13
How to push to a subtree #git
git subtree push --prefix client/dist [folder] origin gh-pages [remote branch]
@gaboratorium
gaboratorium / Regular class
Last active June 8, 2016 20:23
C# Generics: 1.: Regular class #csharp #generics
public class Commander
{
public void Deploy(object value)
{
//Deploy
}
public object this[int index]
{
//Report
get { throw new NotImplementedException(); }
@gaboratorium
gaboratorium / Generic class
Created June 8, 2016 20:26
C# Generics: 2.: Generic class #csharp #generics Raw
public class GenericClass<T>
{
public void Add(T value)
{
//Deploy
}
public T this[int index]
{
get { throw new NotImplementedException(); }
@gaboratorium
gaboratorium / Atom keymap
Created July 7, 2016 09:03
Atom keymapping for linear tab switching #atom
'body':
'ctrl-tab ^ctrl': 'unset!'
'ctrl-tab': 'pane:show-next-item'
'ctrl-shift-tab ^ctrl': 'unset!'
'ctrl-shift-tab': 'pane:show-previous-item'