Skip to content

Instantly share code, notes, and snippets.

@bogvsdev
bogvsdev / sorting.js
Last active March 29, 2016 19:02
js sorting of object
var sort_by = function(field, reverse, primer){
var key = primer ?
function(x) {return primer(x[field])} :
function(x) {return x[field]};
reverse = !reverse ? 1 : -1;
return function (a, b) {
return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
}
$('[name="image"]').on('change',function(evt){
if (!window.File && !window.FileReader && !window.FileList && !window.Blob)
return false;
var file = evt.target.files[0]; // FileList object
// Only process image files.
if (!file.type.match('image.*')) {
return;
}
var reader = new FileReader();
// Read in the image file as a data URL.
@bogvsdev
bogvsdev / google-map.js
Created June 7, 2016 16:56
Simple marker on google map without getting api key
// In html
// <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
// In js
var map = {
init: function(){
var mlatlang = new google.maps.LatLng(33.8633401, -117.8517839);
var mapOptions = {
center: mlatlang,
zoom: 15,
scrollwheel: false
@bogvsdev
bogvsdev / center-image.html
Created June 8, 2016 16:17
centering image
<div class="image-wrapper">
<table class="iw">
<tr>
<td>
<img src="images/products/dmx4308.gif" alt="4">
</td>
</tr>
</table>
</div>
@bogvsdev
bogvsdev / README.md
Created July 30, 2016 09:46
ConEmu Material Theme with settings

ConEmu Material Theme with settings

This is a saved file with settings for my ConEmu with Material Theme color scheme.

To install just import xml file.

@bogvsdev
bogvsdev / .bash_profile
Last active March 11, 2017 22:44
Shortcut command for adding changes to git and publishing it to repository
gitp() {
# get current git branch as string
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
# check for commit message
if [ ${#1} == 0 ]; then
commit='commit'
else
@bogvsdev
bogvsdev / field.sql
Created March 13, 2017 08:22
sql field
select substring(broker1, 0, strpos(broker1, '_') ) as "broker" from "statistic"
@bogvsdev
bogvsdev / main.go
Last active September 30, 2017 19:27
Execution time comparison
package main
import (
"time"
"fmt"
_ "github.com/go-sql-driver/mysql"
"database/sql"
)
func main() {
@bogvsdev
bogvsdev / image_src.html.twig
Last active May 1, 2020 19:14
Drupal 8 twig, get image url
{% set the_image = item.content['#field_collection_item'].field_featurette_image %}
<img src="{{ file_url(the_image.entity.uri.value) }}" alt="{{ the_image.alt }}" title="{{ the_image.title }}">
or
<img src="{{file_url(node.field_hotel_image.entity.uri.value)}}" alt="3242">
@bogvsdev
bogvsdev / pagination.css
Created December 30, 2015 12:49
Bootstrap's pagination styles
.pagination{height:36px;margin:0;padding: 0;}
.pager,.pagination ul{margin-left:0;*zoom:1}
.pagination ul{padding:0;display:inline-block;*display:inline;margin-bottom:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05)}
.pagination li{display:inline}
.pagination a{float:left;padding:0 12px;line-height:30px;text-decoration:none;border:1px solid #ddd;border-left-width:0}
.pagination .active a,.pagination a:hover{background-color:#f5f5f5;color:#94999E}
.pagination .active a{color:#94999E;cursor:default}
.pagination .disabled a,.pagination .disabled a:hover,.pagination .disabled span{color:#94999E;background-color:transparent;cursor:default}
.pagination li:first-child a,.pagination li:first-child span{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}
.pagination li:last-child a{-webkit-border-radius:0 3px 3px 0;