Skip to content

Instantly share code, notes, and snippets.

View gaborpinterweb's full-sized avatar

Gábor Pintér gaborpinterweb

View GitHub Profile
@gaborpinterweb
gaborpinterweb / 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]
@gaborpinterweb
gaborpinterweb / 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 {
/* ... */
}
@gaborpinterweb
gaborpinterweb / 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"))
@gaborpinterweb
gaborpinterweb / 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%
*/
@gaborpinterweb
gaborpinterweb / email_sending.php
Created April 19, 2016 16:21
Sending an e-mail with PHP
<?php
$headers =
'From: Expozers Team <team@team.com>' . "\r\n" .
'Reply-To: webmaster@yourdot.com' . "\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');
?>
@gaborpinterweb
gaborpinterweb / 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();
?>
@gaborpinterweb
gaborpinterweb / 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