Skip to content

Instantly share code, notes, and snippets.

View xto3na's full-sized avatar

Sergey Ponomarenko xto3na

  • Dnepropetrovsk, Ukraine
View GitHub Profile
@xto3na
xto3na / Tree CHECKED
Created September 21, 2015 07:40
Tree CHECKED
<script type="text/javascript">
$('input[type="checkbox"]').on("click", function() {
var items = $(this).closest("li").find("input");
if ($(this).is(':checked')) {
for(var i = 0; i< items.length; i ++) {
items[i].checked = true;
}
}else {
console.log("false");
for(var i = 0; i< items.length; i ++) {
@xto3na
xto3na / Edit location
Last active October 27, 2015 14:43
Edit location
$('#button-filter').on('click', function(bf) {
var stepCount = 2;
var currentUrl = window.location;
var firstAddr = currentUrl.pathname.toString().match(/^\/[a-z]*\/?/);
window.location = location.protocol + "//" + location.hostname + firstAddr[0] + location.search;
//window.history.go( - stepCount);
bf.stopImmediatePropagation();
});
//OR
@xto3na
xto3na / Text Overflow
Last active September 25, 2015 17:32
Text Overflow
1) max-width: n px(%); word-wrap:break-word; text-overflow: ellipsis; white-space: none;
2) .hyphens {
-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto;
}
3) .word-break {
@xto3na
xto3na / ParseHelper.cs
Created September 25, 2015 19:35
ParseHelper
using System.IO;
using System.Net;
namespace SEO_Analyzer.Helpers
{
public class ParseHelper
{
public static string DownloadHtml(string uri)
{
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
@xto3na
xto3na / chown
Created October 8, 2015 00:08
sudo chown -R www-data /путь/к корню/сайта/
sudo chown -R www-data /путь/к корню/сайта/
@xto3na
xto3na / Цикличный обратный отсчет на JS
Created October 14, 2015 13:37
Цикличный обратный отсчет на JS
/******************** Обратный отсчет *************************/
var month = new Date().getMonth() + 1;
if (month == 0) {month++;};
console.log(month);
var currentDate = new Date();
var futureDate = new Date(2015, month, 1);
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
/*var diff = 3600 * 24 * 20.17535;*/
@xto3na
xto3na / Breadcrumb - remove last href...js
Last active December 7, 2015 18:52
Breadcrumb - remove last href...
$(".breadcrumb>li:last>a").removeAttr("href").css("cursor", "default").css("font-weight", "600");
$(".breadcrumb>li:last>a").on("click", function(ev) {
ev.preventDefault();
});
@xto3na
xto3na / CENTER ELEMENT - position: absolute;.css
Last active December 7, 2015 18:52
CENTER ELEMENT - position: absolute;
.element {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%);
transform: translateY(-50%);
}
@xto3na
xto3na / get-watchers.js
Created October 18, 2015 13:38 — forked from kentcdodds/get-watchers.js
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
<snippet>
<content><![CDATA[
<!-- begin $1 -->
<div class="$1">
$2
</div>
<!-- end $1 -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>di</tabTrigger>