Skip to content

Instantly share code, notes, and snippets.

@Maxghp
Maxghp / Stop all vimeo video
Created January 8, 2018 11:02
Stop all vimeo video when close modal
//stop all vimeo videos when close
//jquery require
$(function(){
$('.modal, .close').click(function(){
$("iframe").each(function() {
var src= $(this).attr('src');
$(this).attr('src',src);
});
});
});
@Maxghp
Maxghp / config.php
Created December 28, 2017 13:25
Creating config file for all define in php
<?php
// creating associate array with all parameters
$config = [
'param_1' => 'value_1'
'param_2' => 'value_2'
'param_3' => 'value_3'
];
sudo nano /etc/crontab
import json
from pprint import pprint
from inspect import getmembers
with open('items.json') as data_file:
links = json.load(data_file)
separate_links = []
for link in links:
separate_links.append(link)
@Maxghp
Maxghp / #double dict cycle for key => value (value have random elements)
Created October 20, 2016 13:00
#double dict cycle for key => value (value have random elements)
#double dict cycle for key => value (value have random elements)
with open('items.json') as data_file:
links = json.load(data_file)
start_urls = []
start_urls1 = []
for link in links:
start_urls.append(link)
for urls in start_urls:
for url in urls['link']:
start_urls1.append("http://www.investopedia.com" + url)
@Maxghp
Maxghp / double cycle
Created October 17, 2016 13:24
Python
alphabeticals = [
['A', 13], ['B', 9], ['C', 20], ['D', 13], ['E', 10], ['F', 8], ['G', 6], ['H', 7], ['I', 11], ['J', 3],
['K', 2], ['L', 6], ['M', 13], ['N', 7], ['O', 6], ['P', 13], ['Q', 3], ['R', 9], ['S', 20], ['T', 8],
['U', 4], ['V', 8], ['W', 8], ['X', 2], ['Y', 1], ['Z', 1], ['0', 3]
]
start_urls = []
for alphabetical in alphabeticals:
i = 1
while i <= alphabetical[1]:
for($col = 'A'; $col !== 'G'; $col++) {
$objPHPExcel->getActiveSheet()
->getColumnDimension($col)
->setAutoSize(true);
}
@Maxghp
Maxghp / Example of ajax query
Last active May 23, 2016 11:13
Example of ajax query
//This ajax query is in getpunchtotal.phtml and call /application/index/getpunchadmin view and send user_id and data for
//getpunchadminAction, and that in turn returns.
$('.show-hide').click(function () {
event.preventDefault();
var link = $(this);
var icon = link.find('span');
var table = link.next('table');
var user_id = link.attr('data-user_id');
if (icon.hasClass('glyphicon-plus')) {
icon.addClass('glyphicon-minus').removeClass('glyphicon-plus');
$from_time = strtotime($from_date);
$to_time = strtotime($to_date);
$difference = round(abs($to_time - $from_time) / 60); degree on 60 it converts all in minutes