Skip to content

Instantly share code, notes, and snippets.

View tcdevs's full-sized avatar

TC Devs tcdevs

  • Technische Centrale
View GitHub Profile
@dahnielson
dahnielson / UUID.php
Last active July 18, 2024 08:32
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
@furf
furf / 0-angular-tree.js
Last active July 21, 2016 06:36
A minimal recursive tree directive for Angular.js. Demo: http://jsfiddle.net/furf/EJGHX/
var app = angular.module('app', []);
app.directive('yaTree', function () {
return {
restrict: 'A',
transclude: 'element',
priority: 1000,
terminal: true,
compile: function (tElement, tAttrs, transclude) {
@juliuscsurgo
juliuscsurgo / Bootstrap: no blue glow
Created January 3, 2013 01:29
Twitter Bootstrap: remove the blue glow in the form inputs
input[type="text"], textarea {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
@bgrins
bgrins / Log-.md
Last active July 11, 2024 13:40
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@SneakyBrian
SneakyBrian / CAPTCHA.js
Created March 20, 2013 22:47
Implementing CAPTCHA client-side using HTML5 canvas
(function (window, document, $, undefined) {
var possibleCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var defaults = {
selector: "#captcha",
text: null,
randomText: true,
randomColours: true,
@nicbell
nicbell / 1_primitive_comparison.js
Last active September 23, 2022 16:56
JavaScript object deep comparison. Comparing x === y, where x and y are values, return true or false. Comparing x === y, where x and y are objects, returns true if x and y refer to the same object. Otherwise, returns false even if the objects appear identical. Here is a solution to check if two objects are the same.
//Primitive Type Comparison
var a = 1;
var b = 1;
var c = a;
console.log(a == b); //true
console.log(a === b); //true
console.log(a == c); //true
console.log(a === c); //true
@colthreepv
colthreepv / angular-throttle.js
Last active January 10, 2018 12:07
throttle function for AngularJS. Original one: https://github.com/cowboy/jquery-throttle-debounce
angular.module('helperFunctions', [])
.factory('throttle', ['$timeout', function ($timeout) {
return function (delay, no_trailing, callback, debounce_mode) {
var timeout_id,
last_exec = 0;
if (typeof no_trailing !== 'boolean') {
debounce_mode = callback;
callback = no_trailing;
no_trailing = undefined;
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@BFTrick
BFTrick / remove-nf-required-fields-string.php
Created November 5, 2013 22:18
Remove the Ninja Forms required fields string above a form with 1+ required strings.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_nf_required_fields_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Fields marked with a * are required' :
$translated_text = __( '', 'ninja-forms' );