Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / golang-get-http.go
Created October 24, 2016 20:00
HTTP request on GoLang
package main
import (
//"os"
"encoding/csv"
"fmt"
"strconv"
"sort"
"time"
"net/http"
@hsleonis
hsleonis / golang-readfile-function.go
Created October 24, 2016 19:46
Read file and use CSV data in GoLang
package main
import (
"os"
"encoding/csv"
"fmt"
"strconv"
"sort"
"time"
)
@hsleonis
hsleonis / golang-control-flow.go
Created October 24, 2016 12:14
Basic GoLang control flow
package main
import (
"fmt"
"strconv"
)
func main(){
var x int // Declare variable
@hsleonis
hsleonis / starter-golang.go
Created October 24, 2016 09:09
Variable and type in GoLang
package main
import (
"fmt"
)
func main(){
x,y:=3,4 // Assignment
x,y=y,x // Swap
@hsleonis
hsleonis / php-file-download.php
Created October 17, 2016 12:24
Download file to server with PHP
<?php
// file_put_contents("MoviePy.zip", fopen("https://github.com/Zulko/moviepy/archive/master.zip", 'r'));
function downloadFile($url, $path)
{
$newfname = $path;
$file = fopen ($url, 'rb');
@hsleonis
hsleonis / php-two-row-elements.php
Created October 10, 2016 11:37
Prints two row with single items
<?php
// Items
$n = 18;
$iterator = ($n>4)?2:1;
echo '[ CONTAINER ]<br />';
for($i=0;$i<$n;$i+=$iterator){
echo '[ * col * ]';
echo "{ item ".($i)." }";
if(($n==5 && $i==2) or ($n==6 && $i==4)) {
@hsleonis
hsleonis / collection-vendor-type.liquid
Last active October 10, 2016 07:26
Shopify list product types in a collection by vendor
{% for collection in collections %}
{% for product_type in collections[collection].all_types %}
<li><a href="/collections/{{ collection.handle }}/{{ product_type | handleize }}">{{ product_type }}</a></li>
{% endfor %}
{% endfor %}
@hsleonis
hsleonis / snippet.liquid
Created September 21, 2016 11:51
Shopify break 50 blog post limit
<!--
Shopify has a limit of 50 post per page, but I needed an image gallery in Masonry style with all images.
So I've created different blogs for each type and added images as post featured image.
Thus I can upload unlimited images, broken down into separate blogs.
-->
{% assign gallery = "gallery-ss16, gallery-ss17, gallery-ss17-1" | split: ", " %}
{% for i in gallery %}
{% for article in blogs[i].articles %}
{% if article.image %}
<div class="grid-item {% for tag in article.tags %}{{tag}}{% endfor %}">
@hsleonis
hsleonis / theme-demo-install.txt
Created July 13, 2016 11:34
Create one click theme demo data installer
http://wordpress.stackexchange.com/questions/158443/one-click-demo-content-installation-feature-in-wordpress-theme-options-panel
@hsleonis
hsleonis / parse-website-meta-info.php
Last active June 10, 2016 06:03
get_meta_tags — Extracts all meta tag content attributes from a file and returns an array
<?php
/*
array get_meta_tags ( string $filename [, bool $use_include_path = false ] )
(PHP 4, PHP 5, PHP 7)
ref.: http://php.net/manual/en/function.get-meta-tags.php
*/
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');