Skip to content

Instantly share code, notes, and snippets.

@felipetavares
felipetavares / simple_useful_slow.js
Last active December 15, 2020 12:39
Simple, Useful and Slow: Assorted Reference Statistics Functions (utf-8)
// Simple, Useful and Slow
// Assorted Reference Statistics Functions
// UTF-8 Edition
// Shorthands
pow = Math.pow
sqrt = Math.sqrt
pi = Math.PI
@mdamien
mdamien / 0readme.md
Last active February 22, 2024 12:11
404 link detector with scrapy

List all the broken links on your website

Requirements:

python3 and scrapy (pip install scrapy)

Usage

  • scrapy runspider -o items.csv -a site="https://yoursite.org" 1spider.py
  • python3 2format_results.py
SELECT TOP 20
(SELECT CAST(SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END
- qs.statement_start_offset)/2) + 1) AS NVARCHAR(MAX)) FOR XML PATH(''),TYPE) AS [TSQL],
qs.execution_count AS [#],
CAST(qs.total_worker_time/1000./1000. AS numeric(30,1)) AS [cpu sec],
CASE WHEN execution_count = 0 THEN 0 ELSE
@justinwinslow
justinwinslow / gist:7994944
Last active December 31, 2015 13:48
Angular ui-router breadcrumbs
// State example:
//
// $stateProvider
// .state('state', {
// url: 'state/:id',
// template: stateTemplate,
// controller: stateController,
// // Expose parameters in display names using {:param} syntax
// displayName: 'State ({:id})'
// });
@mgol
mgol / chrome-angularjs.js
Last active November 22, 2021 15:23
Chrome DevTools Snippet for AngularJS apps.
var ngAppElem = angular.element(document.querySelector('[ng-app]') || document);
window.$injector = ngAppElem.injector();
window.inject = $injector.invoke;
window.$rootScope = ngAppElem.scope();
// getService('auth') will create a variable `auth` assigned to the service `auth`.
var getService = serviceName =>
inject([serviceName, s => window[serviceName] = s]);
@norcross
norcross / validate-passwords.js
Created January 19, 2013 00:33
some basic javascript password validation
// **************************************************************
// password validation
// **************************************************************
function checkPassword(pass) {
var numbers = pass.match(/\d+/g);
var uppers = pass.match(/[A-Z]/);
var lowers = pass.match(/[a-z]/);
var special = pass.match(/[!@#$%\^&*\+]/);
@mbemowski
mbemowski / ngGrid.js
Created September 17, 2012 13:49 — forked from dalcib/ngGrid.js
Angular Grid
/**
* Grid directive for angularJS, based on dalcib's Angular Grid https://gist.github.com/2630138
* It's events are more angular-style and it operates on special object NavigationVector. It allows
* to select a row and to add custom rows at the bottom (for example to notify, that there are no rows found)
* When creating NavigationVector object you should pass the scope in which it will be declared in order
* to properly bind $watch expressions. Thanks to this you will be able to update index, selected or even
* items properties and other properties will be updated to match the change you made.
*
* Example:
<table ng-grid="" width="100%">
@nthx
nthx / TamperMonkeyScriptWithJqueryAndSugar.js
Created September 3, 2012 01:36
Hello World TamperMonkey script with jquery/sugarjs
// ==UserScript==
// @match https://yourwebsite.com/xyz
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/sugar/1.3/sugar.min.js
// ==/UserScript==
alert('Hello, I got jQuery included and sugarJs too');
var runEverySecond = function(){
$('p').find('img').attr('width', '0px');
@skunkbad
skunkbad / MY_Controller.php
Created December 20, 2011 22:31
CodeIgniter 2.1.0 form validation external callbacks
<?php if( ! defined('BASEPATH') ) exit('No direct script access allowed');
/**
* CodeIgniter 2.1.0 form validation external callbacks.
*
* This is part of MY_Controller.php in Community Auth, which is an open
* source authentication application for CodeIgniter 2.1.0
*
* @package Community Auth
* @author Robert B Gottier
* @copyright Copyright (c) 2011, Robert B Gottier.
@wojtha
wojtha / gist:1034262
Created June 19, 2011 13:16
PHP Syntax Check for Git pre-commit hook for Windows PowerShell
###############################################################################
#
# PHP Syntax Check for Git pre-commit hook for Windows PowerShell
#
# Author: Vojtech Kusy <wojtha@gmail.com>
#
###############################################################################
### INSTRUCTIONS ###