Author: admin

Use a different git push url

I just came across the problem that i wanted to push some changes in a repository which didn’t have commit rights, since it was only configured via deploy keys. It turned out that it’s possible to seperate the pull and push urls and their corresponding credentials.

With

git remote -v

origin git@github.com:User/forked.git (fetch)
origin git@github.com:User/forked.git (push)

you get a list of those.

git remote set-url --push origin https://ds@xyz.org/git/url.git

sets a different user/url for the current repository. Then you can just push with


git push

Using javascript strict mode with local scoping

To instruct the browser to use more restrictive javascript mode, it is possible to use a “use strict” directive in javascript context. This feature is possible since EcmaScript Version 5.

Example:

1
2
3
4
5
(function () {
    "use strict";
    // Strict code comes in here
 
}());

Another example in HTML body context:

1
2
3
4
5
6
<script type="text/javascript">
    "use strict";
    // Strict code comes in here
    foo = 123; // this is not possible anymore..
    var bar = 123; // but this is
</script>

And again in HTML body context, but with local scoping:

1
2
3
4
5
6
7
<script type="text/javascript">
(function () {
    "use strict";
    // Strict code comes in here
 
}());
</script>

The Strict mode has the following restrictions and exceptions:

  • The identifiers “implements”, “interface”, “let”, “package”, “private”, “protected”, “public”, “static”, and “yield” are classified as FutureReservedWord tokens within strict mode code. (7.6.12 [?]).
  • A conforming implementation, when processing strict mode code, may not extend the syntax of NumericLiteral (7.8.3) to include OctalIntegerLiteral as described in B.1.1.
  • A conforming implementation, when processing strict mode code (see 10.1.1), may not extend the syntax of EscapeSequence to include OctalEscapeSequence as described in B.1.2.
  • Assignment to an undeclared identifier or otherwise unresolvable reference does not create a property in the global object. When a simple assignment occurs within strict mode code, its LeftHandSide must not evaluate to an unresolvable Reference. If it does a ReferenceError exception is thrown (8.7.2). The LeftHandSide also may not be a reference to a data property with the attribute value {[[Writable]]:false}, to an accessor property with the attribute value {[[Set]]:undefined}, nor to a non-existent property of an object whose [[Extensible]] internal property has the value false. In these cases a TypeError exception is thrown (11.13.1).
  • The identifier eval or arguments may not appear as the LeftHandSideExpression of an Assignment operator (11.13) or of a PostfixExpression (11.3) or as the UnaryExpression operated upon by a Prefix Increment (11.4.4) or a Prefix Decrement (11.4.5) operator. Arguments objects for strict mode functions define non-configurable accessor properties named “caller” and “callee” which throw a TypeError exception on access (10.6).
  • Arguments objects for strict mode functions do not dynamically share their array indexed property values with the corresponding formal parameter bindings of their functions. (10.6). For strict mode functions, if an arguments object is created the binding of the local identifier arguments to the arguments object is immutable and hence may not be the target of an assignment expression. (10.5).
  • It is a SyntaxError if strict mode code contains an ObjectLiteral with more than one definition of any data property (11.1.5). It is a SyntaxError if the Identifier “eval” or the Identifier “arguments” occurs as the Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code or if its FunctionBody is strict code (11.1.5).
  • Strict mode eval code cannot instantiate variables or functions in the variable environment of the caller to eval. Instead, a new variable environment is created and that environment is used for declaration binding instantiation for the eval code (10.4.2).
  • If this is evaluated within strict mode code, then the this value is not coerced to an object. A this value of null or undefined is not converted to the global object and primitive values are not converted to wrapper objects. The this value passed via a function call (including calls made using Function.prototype.apply and Function.prototype.call) do not coerce the passed this value to an object (10.4.3, 11.1.1, 15.3.4.3, 15.3.4.4).
  • When a delete operator occurs within strict mode code, a SyntaxError is thrown if its UnaryExpression is a direct reference to a variable, function argument, or function name(11.4.1).
  • When a delete operator occurs within strict mode code, a TypeError is thrown if the property to be deleted has the attribute { [[Configurable]]:false } (11.4.1). It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code and its Identifier is eval or arguments (12.2.1).
  • Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such a context is an SyntaxError (12.10).
  • It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is eval or arguments (12.14.1)
  • It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)
  • A strict mode function may not have two or more formal parameters that have the same name. An attempt to create such a function using a FunctionDeclaration, FunctionExpression, or Function constructor is a SyntaxError (13.1, 15.3.2).
  • An implementation may not extend, beyond that defined in this specification, meanings within strict mode functions of properties named caller or arguments of function instances. ECMAScript code may not create or modify properties with these names on function objects that correspond to strict mode functions (10.6, 13.2, 15.3.4.5.3).
  • It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name (13.1). Attempting to dynamically define such a strict mode function using the Function constructor (15.3.2) will throw a SyntaxError exception.

More about strict mode: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode

Nice Slide Up and Slide Down animations build with CSS3

.slideDown {
 animation-name: slideDown;
 -webkit-animation-name: slideDown;
 
 animation-duration: .8s;
 -webkit-animation-duration: .8s;
 
 animation-timing-function: ease;
 -webkit-animation-timing-function: ease;
 
 visibility: visible !important;
}
 
@keyframes slideDown {
 0% {
 transform: translateY(-100%);
 }
 65%{
 transform: translateY(5%);
 }
 100% {
 transform: translateY(0%);
 }
}
 
@-webkit-keyframes slideDown {
 0% {
 -webkit-transform: translateY(-100%);
 }
 65%{
 -webkit-transform: translateY(5%);
 }
 100% {
 -webkit-transform: translateY(0%);
 }
}
 
.slideUp {
 animation-name: slideUp;
 -webkit-animation-name: slideUp;
 
 animation-duration: .8s;
 -webkit-animation-duration: .8s;
 
 animation-timing-function: ease;
 -webkit-animation-timing-function: ease;
 
 animation-fill-mode: both;
 -webkit-animation-fill-mode: both;
}
 
@keyframes slideUp {
 0% {
 transform: translateY(0%);
 }
 65%{
 transform: translateY(5%);
 }
 100% {
 transform: translateY(-150%);
 }
}
@-webkit-keyframes slideUp {
 0% {
 -webkit-transform: translateY(0%);
 }
 65%{
 -webkit-transform: translateY(5%);
 }
 100% {
 -webkit-transform: translateY(-150%);
 
 }
}

Export HTML Table as CSV

This neat little prototype script is able to export a regular HTML table as CSV an offers it for download: https://github.com/dstuecken/exportTableAsCSV

iconv script to convert iso-8895-1 files in a web project to utf-8

1
2
3
4
5
6
7
8
#!/bin/bash
 
for file in `find . -name '*.php' -or -name '*.tpl' -or -name '*.css' -or -name '*.js'| xargs file --mime | grep 'iso-8859-1' | awk '{gsub(/:/,"",$1); print $1}'`; do
  echo "Converting ${file}.."
  mv $file $file.iconv
  iconv -f ISO-8859-1 -t UTF-8 $file.iconv &gt; $file
  rm -f $file.iconv
done

Ubuntu upgrade via console

1
2
 apt-get install update-manager-core
 vi /etc/update-manager/release-upgrades

-> Prompt=normal;

1
 do-release-upgrade -d

Smooth scrolling in jQuery

1
2
3
4
5
6
if ($("#elementToScrollTo").offset().top < 0)
{
  $('body').animate({ // or ccroll context as CSS Selector
    scrollTop: $("#elementToScrollTo").offset().top
  }, 400);
}

Assembler HEX Table

0F82 oder 72 jb jump if below
0F83 oder 73 jnb jump if not below
0F84 oder 74 je jump if equal
0F85 oder 75 jne jump if not equal
0F86 oder 76 jbe jump if below or equal
0F87 oder 77 ja jump if above
0F83 jae jump if above or equal
0F86 jna jump if not above
0F82 jnae jump if not above or equal
0F87 jnbe jump if not below or equal
0F8F jg jump if greater
0F8E jng jump if not greater
0F8D jge jump if greater or equal
0F8C jnge jump if not greater or equal
0F8C jl jump if less
0F8D jnl jump if not less
0F8E jle jump if less or equal
0F8F jnle jump if not less or equal
EB jmp oder jmps jump direcly to
84 test test
90 nop no operation

Simulating mouse events in javascript

Mouse click simulation via javascript:

1
2
3
4
5
6
7
if (!HTMLElement.click) {
  HTMLElement.prototype.click = function() {
    var evt = this.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    this.dispatchEvent(evt);
  }
}

Usage: document.getElementById(‘my-element’).click()

HTMLElement.click should be defined in Internet Explorer by default.

MAC OS X: Add users to UNIX group(s)

Here you go:

dseditgroup -o edit -u yourusername -p -a <em>username</em> -t user group

© 2016 dsblog

Theme by Anders NorenUp ↑