Skip to content

Instantly share code, notes, and snippets.

@alirezamirian
alirezamirian / angular-diagnostics.js
Last active October 1, 2016 10:24
A try for adding debugging info when each of the methods of directives controller gets called. It neither work correctly nor is configurable yet to set which directives to diagnose (you should hardcode it!). I'm just pushing it as a draft
angular.module("diagnostics", [])
.run(function($injector, $controller, $log){
var directivesToInspect = [];
directivesToInspect.forEach(function(directiveName){
$injector.get(directiveName + "Directive").forEach(function(directive){
if(angular.isArray(directive.controller)){
var Ctrl = directive.controller[directive.controller.length-1];
directive.controller[directive.controller.length-1] = function(){
var locals = {};
for(var i=0; i<arguments.length; i++){
@alirezamirian
alirezamirian / README.md
Last active January 9, 2017 07:35
persian-recruitee

Persian Recruitee

Make your recruitee subdomain right-to-left and Persian by simply adding a couple of files to Custom CSS/JS section.

Usage

Add the following lines to Custom CSS/JS section:

<link href="https://rawgit.com/alirezamirian/fa346c4ddbc668afcc15c95afa7cf5e2/raw/styles.css" rel="stylesheet" />
<script src="https://rawgit.com/alirezamirian/fa346c4ddbc668afcc15c95afa7cf5e2/raw/scripts.js"></script>

Translation table

@alirezamirian
alirezamirian / four-letter-game-auto-responder.js
Last active January 31, 2017 19:50
Creates an object for automatically responding to your opponent's guesses in 4-harfi game using Airdroid
/**
* Creates an object for automatically responding to your opponent's guesses in 4-harfi game using Airdroid.
* If you don't have an idea about what 4-harfi game is that's absolutely normal! However if you don't know Airdroid,
* you are missing a really useful android app.
*
* @param word your guess
* @param prevGuess previously guessed word, use it if you want to start automation while already started game.
* @returns {{stop: stop, start: start}}
* start: starts auto responding
* stop: stops auto responding
@alirezamirian
alirezamirian / demo.gif
Last active July 11, 2017 07:49
A simple angular module for animating delete buttons using md-button
demo.gif
class RefController {
constructor($element, $scope, $parse, $attrs){
'ngInject';
const tagName = $attrs.refOf || $attrs.$normalize($element[0].tagName.toLowerCase());
let instance = $element.controller(tagName);
if (!instance && !$attrs.refOf) {
instance = $element;
}
$parse($attrs.ref).assign($scope, instance);
}
@alirezamirian
alirezamirian / nested-ui-bootstrap-dropdown.module.js
Last active December 10, 2017 07:54 — forked from sebastianhenneberg/dropdownServicePatch.js
Replaces uibDropdownService of angular-ui/bootstrap to support nested dropdowns
(function () {
'use strict';
/**
* This monkey-patch for the dropdownService enables to nest dropdowns.
* Issue: https://github.com/angular-ui/bootstrap/issues/2421
* PR: https://github.com/angular-ui/bootstrap/pull/3776
*/
@alirezamirian
alirezamirian / jira-rtl-fix.js
Last active January 5, 2019 11:23
A script to be used in greasemonkey or similar tools to fix rtl issues in jira
// ==UserScript==
// @name jira rtl fix
// @namespace http://tampermonkey.net/
// @version 0.1
// @description fixes rtl issues in jira
// @author Alireza Mirian
// @include /^https?://jira\..*$/
// @grant none
// ==/UserScript==
it('should handle uncontrolled value and change callback', () => {
const onToggleSpy = jest.fn();
const { clickHeader } = mountUsage(<Zippy header={'header'} onToggle={onToggleSpy}/>);
clickHeader();
expect(onToggleSpy).toBeCalledWith(true);
clickHeader();
expect(onToggleSpy).toBeCalledWith(false);
expect(onToggleSpy).toHaveBeenCalledTimes(2);
});
it('should work in controlled mode', () => {
class ControlledUsage extends React.Component<{}, { counter: number, open: boolean }> {
constructor(props) {
super(props);
this.toggle = this.toggle.bind(this);
}
state = {
counter: 0,
open: true,
it('should work when value is controlled but changes are ignored (readonly mode)', () => {
const { clickHeader, isOpen } = mountUsage(<Zippy header={'header'} open={true}/>);
expect(isOpen()).toEqual(true);
clickHeader();
expect(isOpen()).toEqual(true);
clickHeader();
expect(isOpen()).toEqual(true);
});