Skip to content

Instantly share code, notes, and snippets.

<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../paper-calculator/paper-calculator.html">
<polymer-element name="my-element">
<template>
<style>
@IceCreamSushi
IceCreamSushi / EffectiveJs
Last active August 29, 2015 14:05
Effective Javascript notes
1. separate scopes and use stric :
(function() { "use strict"; function f(){...} })();
2. js numbers ~= doubles.
Thus: 0.1+0.2 = 0.30000000004... O_O
And (0.3 + 0.2) + 0.1 != 0.3 + (0.2+0.1)
So, to bypass the non-associativity, one should use a scale. E.g: myInt = myFloat*100000 and after the computation, divide by 100000
3. There are 7 false var : false, 0, -0, "", NaN, null and undefined. Thus, "false" is true.
+ gives priority to string rather than int. It's overloaded for concatenation of strings.
== Clearfix hack ==
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
=== FLOAT 9 RULES ===
1- Floated elements are pushed to the edge of their containers, no further.
2- Any floated element will either appear next to or below a previous floated element. If the elements are floated left, the second element will appear to the right of the first. If they’re floated right, the second element will appear to the left of the first.
3- A left-floating box can’t be further right than a right-floating box.
4- Floated elements can’t go higher than their container’s top edge (this gets more complicated when collapsing margins are involved, see original rule).
5- A floated element can’t be higher than a previous block level or floated element.
6- A floated element can’t be higher than a previous line of inline elements.
7- One floated element next to another floated element can’t stick out past the edge of its container.
8- A floating box must be placed as high as possible. (No translation necessary)
9- A left-floating box must be put as far to the left as possible, a right-floating box as
@IceCreamSushi
IceCreamSushi / ScriptShells
Created July 3, 2014 16:57
Random useful scriptshells
== Random useful scriptshells ==
-- Copy all imgs in recursive dirs into the same --
find . -type f -name '*.jpg' -exec cp {} /home/new_dir/{} \;
== JAR Inclusion ==
Please, don't just copy/past a jar file on eclipse to add the library. Right clic -> Build Path -> Add external jar. Sometimes, the Manifest.mf of the jar contains other dependencies required by the lib.
@IceCreamSushi
IceCreamSushi / Android: hide keyboard
Created May 7, 2014 11:37
If I want to hide the keyboard when somebody click anywhere else but on the edittext
// in onCreate
relative = (RelativeLayout) rootView.findViewById(R.id.relative_layout);
relative.setOnClickListener(this);
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_send:
sendStory();
break;
@IceCreamSushi
IceCreamSushi / Android: sharePref
Created May 7, 2014 11:20
Basic SharePref to store data
public class Calc extends Activity {
public static final String PREFS_NAME = "MyPrefsFile";
@Override
protected void onCreate(Bundle state){
super.onCreate(state);
. . .
// Restore preferences
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
@IceCreamSushi
IceCreamSushi / Hex usefull values
Last active August 29, 2015 14:00
Hex values I use often
== Hex format for opacity ==
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
@IceCreamSushi
IceCreamSushi / Android: Toast
Created April 30, 2014 09:45
Just send a Toast.
Toast.makeText(MainActivity.this, "Miam", Toast.LENGTH_SHORT).show();