Skip to content

Instantly share code, notes, and snippets.

@finalfantasia
finalfantasia / the_right_ways_of_writing_css.md
Last active September 13, 2019 14:41
The "Right Ways" of Writing CSS

Separate Structure and Skin

This means to define repeating visual features as separate “skins” that you can mix-and-match with your various objects to achieve a large amount of visual variety without much code. This also means using classes to name your objects and their components, rather than relying solely on the semantics of HTML.

Separate Container and Content

Essentially, this means “rarely use location-dependent styles”.

Core Goals

@finalfantasia
finalfantasia / spaces.md
Last active August 29, 2015 14:12
Spaces

White space contributes as much to the effect produced by software text as silence to the effect of a musical piece.

The general rule, for simplicity and ease of remembering, is to follow as closely as possible the practice of a standard written language. By default, we will assume this language to be English, although it may be appropriate to adapt the conventions to the slightly different rules of other languages.

Here are some of the consequences. You will use a space:

  • Before an opening parenthesis, but not after: f (x) (not f(x), the C style, or f( x)).
  • After a closing parenthesis unless the next character is a punctuation sign such as a period or semicolon; but not before. Hence: proc1 (x); x := f1 (x) + f2 (y).
  • After a comma but not before: g (x, y, z).
  • After the two dash signs that start a comment: -- A comment.
@finalfantasia
finalfantasia / automatic_semicolon_insertion_in_javascript_everything_you_need_to_know.md
Last active November 4, 2016 17:31
Automatic Semicolon Insertion in JavaScript—Everything You Need to Know

#Automatic Semicolon Insertion in JavaScript—Everything You Need to Know Friday, May 28, 2010

Automatic semicolon insertion is one of JavaScript's most controversial syntactic features. There are also many misconceptions surrounding it.

Some JavaScript programmers use semicolons at the end of every statement and some use them only where strictly required. Most do something in between and a few even intentionally add extra semicolons as a matter of style.

Even if you use semicolons at the end of every statement, some constructs parse in non-obvious ways. Regardless of your preferences in semicolon usage, you must know the rules to write JavaScript professionally. If you remember a few simple rules, all of which are explained here, you will be able to understand how any program you might encounter will be parsed and will be an expert on JavaScript automatic semicolon insertion or ASI.

##Where Semicolons are Allowed

@finalfantasia
finalfantasia / clean_and_stop_creation_of_wdmc_directories_on_wd_my_cloud_ex2.md
Last active September 14, 2015 07:55
Clean and Stop Creation of .wdmc Directories on WD My Cloud EX2
  1. Stop the daemons:
    /etc/init.d/wdmcserverd stop
    /etc/init.d/wdphotodbmergerd stop
  1. Disable the daemons:
    update-rc.d wdphotodbmergerd disable
    update-rc.d wdmcserverd disable
@finalfantasia
finalfantasia / why_functional_programming_has_not_taken_over_yet.md
Created March 3, 2016 18:44
Why functional programming hasn't taken over yet

Because all those advantages are also disadvantages.

Stateless programs; No side effects

Real-world programs are all about side effects and mutation. When the user presses a button it's because they want something to happen. When they type in something, they want that state to replace whatever state used to be there. When Jane Smith in accounting gets married and changes her name to Jane Jones, the database backing the business process that prints her paycheque had better be all about handling that sort of mutation. When you fire the machine gun at the alien, most people do not mentally model that as the construction of a new alien with fewer hit points; they model that as a mutation of an existing alien's properties. When the programming language concepts fundamentally work against the domain being modelled, it's hard to justify using that language.

Concurrency; Plays extremely nice with the rising multi-core technology

The problem is just pushed around. With immutable data structures you have ch

@finalfantasia
finalfantasia / java_generics.md
Last active May 8, 2021 16:32
Java Generics

Terms

  • Generic Type
  • Generic Method
  • Type Parameter
  • Type Argument
  • Parameterized Type
  • Type Erasure
  • Wildcard (?)

Example

@finalfantasia
finalfantasia / todo_list_redux_reducer.js
Last active February 21, 2022 03:30
Todo List Redux Reducer
// <script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.min.js"></script>
// redux api
const combineReducers = reducers =>
(state = {}, action) =>
Object.keys (reducers).
reduce ((accumulator, key) => Object.assign ({}, accumulator, {[key]: reducers [key] (state [key], action)}), {})
@finalfantasia
finalfantasia / react_redux_todo_app.js
Last active November 10, 2016 06:56
React-Redux Todo App
// <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js"></script>
// <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js"></script>
/*
<body>
<div id="root" />
</body>
*/
// redux api
@finalfantasia
finalfantasia / make_arabic_letters_connected_in_emacs.el
Last active January 10, 2017 08:03
Make Arabic Letters Connected in Emacs
;; Evaluate the following to get a list of all typefaces and pick an Arabic typeface from it.
;; (In my case, it was "PakType Naskh Basic".):
(print (font-family-list))
;; Add the following line to ~/.emacs/init.el (or ~/.emacs)
;; (Change the name of the typeface at the end to that of the one you picked above.):
(when window-system
(set-fontset-font "fontset-default" '(#x600 . #x6ff) "PakType Naskh Basic"))
@finalfantasia
finalfantasia / solutions_to_4clojure_problems.clj
Last active March 3, 2025 01:38
Solutions to 4Clojure Problems
;;
;; www.4clojure.com
;;
;; #19 last element
(comp first reverse)
;; (partial reduce (fn [_ x] x))
;; (fn [coll] (reduce (fn [_ x] x) coll))
;; (partial reduce #(identity %2))