Skip to content

Instantly share code, notes, and snippets.

@bogvsdev
bogvsdev / main.go
Last active Sep 30, 2017
Execution time comparison
View main.go
package main
import (
"time"
"fmt"
_ "github.com/go-sql-driver/mysql"
"database/sql"
)
func main() {
View field.sql
select substring(broker1, 0, strpos(broker1, '_') ) as "broker" from "statistic"
@bogvsdev
bogvsdev / .bash_profile
Last active Mar 11, 2017
Shortcut command for adding changes to git and publishing it to repository
View .bash_profile
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 / README.md
Created Jul 30, 2016
ConEmu Material Theme with settings
View README.md

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.

View center-image.html
<div class="image-wrapper">
<table class="iw">
<tr>
<td>
<img src="images/products/dmx4308.gif" alt="4">
</td>
</tr>
</table>
</div>
@bogvsdev
bogvsdev / google-map.js
Created Jun 7, 2016
Simple marker on google map without getting api key
View google-map.js
// 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
View preview-image.js
$('[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 / sorting.js
Last active Mar 29, 2016
js sorting of object
View sorting.js
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));
}
@bogvsdev
bogvsdev / image_src.html.twig
Last active May 1, 2020
Drupal 8 twig, get image url
View image_src.html.twig
{% 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 Dec 30, 2015
Bootstrap's pagination styles
View pagination.css
.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;