text:
# Test Report

## File

**sha256**: `4954bfb1c5e9b8996e1900e03494c3c9a1161fc25f9c78e40fc3a901f251bc7f`  /mnt/c/Users/PatrickF/2017_09_27_250MB.txt

## Dice

`262144000 -c 1 -e "raw" -f "C:\Users\PatrickF\2017_09_27_250MB.txt"`

    Fetch external seed: Hotbits [1427ms] random.org [2106ms] ANU Quantum [2952ms]

    Writing data to C:\Users\PatrickF\2017_09_27_250MB.txt

    [2017-09-27 07:28:27 MESZ][1.0.0] 262144000 bytes generated in 13688 ms.
    Process finished with exit code 0

## Dieharder

`dieharder -a -g 201 -f "/mnt/c/Users/PatrickF/2017_09_27_250MB.txt" > "/mnt/c/Users/PatrickF/2017_09_27_250MB.report.txt"`

### Report

    #=============================================================================#
    #            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
    #=============================================================================#
       rng_name    |           filename             |rands/second|
     file_input_raw|/mnt/c/Users/PatrickF/2017_09_27_250MB.txt|  2.00e+07  |
    #=============================================================================#
            test_name   |ntup| tsamples |psamples|  p-value |Assessment
    #=============================================================================#
       diehard_birthdays|   0|       100|     100|0.48947515|  PASSED
          diehard_operm5|   0|   1000000|     100|0.89342688|  PASSED
      diehard_rank_32x32|   0|     40000|     100|0.99089662|  PASSED
        diehard_rank_6x8|   0|    100000|     100|0.13934072|  PASSED
       diehard_bitstream|   0|   2097152|     100|0.61036291|  PASSED
            diehard_opso|   0|   2097152|     100|0.47180420|  PASSED
            diehard_oqso|   0|   2097152|     100|0.96434458|  PASSED
             diehard_dna|   0|   2097152|     100|0.65304685|  PASSED
    diehard_count_1s_str|   0|    256000|     100|0.22791206|  PASSED
    diehard_count_1s_byt|   0|    256000|     100|0.86074420|  PASSED
     diehard_parking_lot|   0|     12000|     100|0.95327896|  PASSED
        diehard_2dsphere|   2|      8000|     100|0.99130725|  PASSED
        diehard_3dsphere|   3|      4000|     100|0.54163947|  PASSED
         diehard_squeeze|   0|    100000|     100|0.21722591|  PASSED
            diehard_sums|   0|       100|     100|0.49449114|  PASSED
            diehard_runs|   0|    100000|     100|0.57385394|  PASSED
            diehard_runs|   0|    100000|     100|0.51607075|  PASSED
           diehard_craps|   0|    200000|     100|0.99525398|   WEAK
           diehard_craps|   0|    200000|     100|0.05601662|  PASSED
     marsaglia_tsang_gcd|   0|  10000000|     100|0.47833978|  PASSED
     marsaglia_tsang_gcd|   0|  10000000|     100|0.00000000|  FAILED
             sts_monobit|   1|    100000|     100|0.96603080|  PASSED
                sts_runs|   2|    100000|     100|0.82983438|  PASSED
              sts_serial|   1|    100000|     100|0.81461255|  PASSED
              sts_serial|   2|    100000|     100|0.46827081|  PASSED
              sts_serial|   3|    100000|     100|0.86736102|  PASSED
              sts_serial|   3|    100000|     100|0.45131611|  PASSED
              sts_serial|   4|    100000|     100|0.95288591|  PASSED
              sts_serial|   4|    100000|     100|0.77404500|  PASSED
              sts_serial|   5|    100000|     100|0.72948243|  PASSED
              sts_serial|   5|    100000|     100|0.66606036|  PASSED
              sts_serial|   6|    100000|     100|0.99996172|   WEAK
              sts_serial|   6|    100000|     100|0.64916506|  PASSED
              sts_serial|   7|    100000|     100|0.23875953|  PASSED
              sts_serial|   7|    100000|     100|0.04440253|  PASSED
              sts_serial|   8|    100000|     100|0.66665693|  PASSED
              sts_serial|   8|    100000|     100|0.62942784|  PASSED
              sts_serial|   9|    100000|     100|0.98533476|  PASSED
              sts_serial|   9|    100000|     100|0.94927235|  PASSED
              sts_serial|  10|    100000|     100|0.98575310|  PASSED
              sts_serial|  10|    100000|     100|0.65527370|  PASSED
              sts_serial|  11|    100000|     100|0.05379755|  PASSED
              sts_serial|  11|    100000|     100|0.00910083|  PASSED
              sts_serial|  12|    100000|     100|0.28654854|  PASSED
              sts_serial|  12|    100000|     100|0.01286897|  PASSED
              sts_serial|  13|    100000|     100|0.01403812|  PASSED
              sts_serial|  13|    100000|     100|0.18687137|  PASSED
              sts_serial|  14|    100000|     100|0.63924960|  PASSED
              sts_serial|  14|    100000|     100|0.85602582|  PASSED
              sts_serial|  15|    100000|     100|0.23670632|  PASSED
              sts_serial|  15|    100000|     100|0.17291862|  PASSED
              sts_serial|  16|    100000|     100|0.48541954|  PASSED
              sts_serial|  16|    100000|     100|0.68798481|  PASSED
             rgb_bitdist|   1|    100000|     100|0.62595280|  PASSED
             rgb_bitdist|   2|    100000|     100|0.40829351|  PASSED
             rgb_bitdist|   3|    100000|     100|0.38498832|  PASSED
             rgb_bitdist|   4|    100000|     100|0.23360921|  PASSED
             rgb_bitdist|   5|    100000|     100|0.65632511|  PASSED
             rgb_bitdist|   6|    100000|     100|0.12750341|  PASSED
             rgb_bitdist|   7|    100000|     100|0.75709920|  PASSED
             rgb_bitdist|   8|    100000|     100|0.13874714|  PASSED
             rgb_bitdist|   9|    100000|     100|0.02346350|  PASSED
             rgb_bitdist|  10|    100000|     100|0.18768411|  PASSED
             rgb_bitdist|  11|    100000|     100|0.76791433|  PASSED
             rgb_bitdist|  12|    100000|     100|0.76152272|  PASSED
    rgb_minimum_distance|   2|     10000|    1000|0.48928616|  PASSED
    rgb_minimum_distance|   3|     10000|    1000|0.51634917|  PASSED
    rgb_minimum_distance|   4|     10000|    1000|0.26738903|  PASSED
    rgb_minimum_distance|   5|     10000|    1000|0.09840677|  PASSED
        rgb_permutations|   2|    100000|     100|0.79542755|  PASSED
        rgb_permutations|   3|    100000|     100|0.53257880|  PASSED
        rgb_permutations|   4|    100000|     100|0.91366514|  PASSED
        rgb_permutations|   5|    100000|     100|0.26000393|  PASSED
          rgb_lagged_sum|   0|   1000000|     100|0.72912943|  PASSED
          rgb_lagged_sum|   1|   1000000|     100|0.81979009|  PASSED
          rgb_lagged_sum|   2|   1000000|     100|0.51406926|  PASSED
          rgb_lagged_sum|   3|   1000000|     100|0.00344781|   WEAK
          rgb_lagged_sum|   4|   1000000|     100|0.09695073|  PASSED
          rgb_lagged_sum|   5|   1000000|     100|0.16159542|  PASSED
          rgb_lagged_sum|   6|   1000000|     100|0.09103064|  PASSED
          rgb_lagged_sum|   7|   1000000|     100|0.00396441|   WEAK
          rgb_lagged_sum|   8|   1000000|     100|0.20848273|  PASSED
          rgb_lagged_sum|   9|   1000000|     100|0.01509460|  PASSED
          rgb_lagged_sum|  10|   1000000|     100|0.09787284|  PASSED
          rgb_lagged_sum|  11|   1000000|     100|0.12699903|  PASSED
          rgb_lagged_sum|  12|   1000000|     100|0.25785305|  PASSED
          rgb_lagged_sum|  13|   1000000|     100|0.02192806|  PASSED
          rgb_lagged_sum|  14|   1000000|     100|0.02984297|  PASSED
          rgb_lagged_sum|  15|   1000000|     100|0.00140636|   WEAK
          rgb_lagged_sum|  16|   1000000|     100|0.29456770|  PASSED
          rgb_lagged_sum|  17|   1000000|     100|0.16346662|  PASSED
          rgb_lagged_sum|  18|   1000000|     100|0.12683775|  PASSED
          rgb_lagged_sum|  19|   1000000|     100|0.00007955|   WEAK
          rgb_lagged_sum|  20|   1000000|     100|0.44560699|  PASSED
          rgb_lagged_sum|  21|   1000000|     100|0.20796553|  PASSED
          rgb_lagged_sum|  22|   1000000|     100|0.46926582|  PASSED
          rgb_lagged_sum|  23|   1000000|     100|0.00360372|   WEAK
          rgb_lagged_sum|  24|   1000000|     100|0.00000000|  FAILED
          rgb_lagged_sum|  25|   1000000|     100|0.30915755|  PASSED
          rgb_lagged_sum|  26|   1000000|     100|0.49677011|  PASSED
          rgb_lagged_sum|  27|   1000000|     100|0.01251815|  PASSED
          rgb_lagged_sum|  28|   1000000|     100|0.27324770|  PASSED
          rgb_lagged_sum|  29|   1000000|     100|0.00087131|   WEAK
          rgb_lagged_sum|  30|   1000000|     100|0.04100818|  PASSED
          rgb_lagged_sum|  31|   1000000|     100|0.00000006|  FAILED
          rgb_lagged_sum|  32|   1000000|     100|0.20317251|  PASSED
         rgb_kstest_test|   0|     10000|    1000|0.04999679|  PASSED
         dab_bytedistrib|   0|  51200000|       1|0.98480145|  PASSED
                 dab_dct| 256|     50000|       1|0.34802018|  PASSED
    Preparing to run test 207.  ntuple = 0
            dab_filltree|  32|  15000000|       1|0.99052841|  PASSED
            dab_filltree|  32|  15000000|       1|0.03689666|  PASSED
    Preparing to run test 208.  ntuple = 0
           dab_filltree2|   0|   5000000|       1|0.39199517|  PASSED
           dab_filltree2|   1|   5000000|       1|0.48001547|  PASSED
    Preparing to run test 209.  ntuple = 0
            dab_monobit2|  12|  65000000|       1|0.27162681|  PASSED

### Warnings

    # The file file_input_raw was rewound 1 times
    # The file file_input_raw was rewound 3 times
    # The file file_input_raw was rewound 16 times
    # The file file_input_raw was rewound 17 times
    # The file file_input_raw was rewound 19 times
    # The file file_input_raw was rewound 49 times
    # The file file_input_raw was rewound 49 times
    # The file file_input_raw was rewound 50 times
    # The file file_input_raw was rewound 50 times
    # The file file_input_raw was rewound 50 times
    # The file file_input_raw was rewound 51 times
    # The file file_input_raw was rewound 52 times
    # The file file_input_raw was rewound 53 times
    # The file file_input_raw was rewound 54 times
    # The file file_input_raw was rewound 56 times
    # The file file_input_raw was rewound 58 times
    # The file file_input_raw was rewound 61 times
    # The file file_input_raw was rewound 63 times
    # The file file_input_raw was rewound 66 times
    # The file file_input_raw was rewound 70 times
    # The file file_input_raw was rewound 73 times
    # The file file_input_raw was rewound 74 times
    # The file file_input_raw was rewound 74 times
    # The file file_input_raw was rewound 75 times
    # The file file_input_raw was rewound 76 times
    # The file file_input_raw was rewound 76 times
    # The file file_input_raw was rewound 76 times
    # The file file_input_raw was rewound 77 times
    # The file file_input_raw was rewound 78 times
    # The file file_input_raw was rewound 79 times
    # The file file_input_raw was rewound 82 times
    # The file file_input_raw was rewound 87 times
    # The file file_input_raw was rewound 93 times
    # The file file_input_raw was rewound 101 times
    # The file file_input_raw was rewound 110 times
    # The file file_input_raw was rewound 120 times
    # The file file_input_raw was rewound 133 times
    # The file file_input_raw was rewound 146 times
    # The file file_input_raw was rewound 162 times
    # The file file_input_raw was rewound 178 times
    # The file file_input_raw was rewound 197 times
    # The file file_input_raw was rewound 217 times
    # The file file_input_raw was rewound 238 times
    # The file file_input_raw was rewound 261 times
    # The file file_input_raw was rewound 285 times
    # The file file_input_raw was rewound 311 times
    # The file file_input_raw was rewound 339 times
    # The file file_input_raw was rewound 368 times
    # The file file_input_raw was rewound 398 times
    # The file file_input_raw was rewound 430 times
    # The file file_input_raw was rewound 464 times
    # The file file_input_raw was rewound 499 times
    # The file file_input_raw was rewound 536 times
    # The file file_input_raw was rewound 574 times
    # The file file_input_raw was rewound 613 times
    # The file file_input_raw was rewound 655 times
    # The file file_input_raw was rewound 697 times
    # The file file_input_raw was rewound 742 times
    # The file file_input_raw was rewound 787 times
    # The file file_input_raw was rewound 835 times
    # The file file_input_raw was rewound 883 times
    # The file file_input_raw was rewound 934 times
    # The file file_input_raw was rewound 934 times
    # The file file_input_raw was rewound 936 times
    # The file file_input_raw was rewound 936 times
    # The file file_input_raw was rewound 938 times
    # The file file_input_raw was rewound 939 times
    # The file file_input_raw was rewound 940 times

repository: patrickfav/dice

repo_name: patrickfav/dice


text:
# Contributing to stowage

Stowage is a small free software project. It welcomes contributions of all types!

## Before filing an issue

Feel free to file bugs. If something isn't a bug, it probably means the documentation or design has a deficiency, so that has value too.

## Filing issues

Sensitive security-related issues should be reported to privately to the main author wherever possible; I treat security issues very seriously and will respond as quickly as possible.

Otherwise, when filing an issue, make sure to answer these five questions:

1. What version of stowage are you using (`stowage help` will show this, if you built from
   source please reference the commit you used)?
2. What operating system and processor architecture are you using?
3. What did you do?
4. What did you expect to see?
5. What did you see instead?

For enhancements, I like receiving user stories that demonstrate the use case and the value of the proposal.

## Contributing code

Please read the [code of conduct](CODE_OF_CONDUCT.md) before sending patches.

GitHub pull requests are absolutely fine; however, I reserve the right to grab the patches, alter them around a lot and commit that instead of the accepting the PR.

Please ensure that you are licensing your changes under the same terms as the original project, and that you have the ability or permission (Where required) to publish changes.

license: MIT

repository: alexhudson/stowage

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: alexhudson/stowage


text:
# Custom JEI

## 导包

~~~zenscript
import mods.jei.JEI;
~~~

| 方法                                                         | 返回值                                                       | 备注                                                         |
| :----------------------------------------------------------- | :----------------------------------------------------------- | ------------------------------------------------------------ |
| createJEIPanel(uid as string, localizationKey as string)     | [JEIPanel](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIPanel.md) |                                                              |
| createJEIBackground(width as int, height as int)             | [JEIBackground](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIBackground.md) |                                                              |
| createJEIBackground(resourceName as string, u as int, v as int, width as int, height as int) | [JEIBackground](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIBackground.md) |                                                              |
| createLiquidSlot(isInput as bool, x as int, y as int, @Optional(valueBoolean = true) hasBase as bool) | [JEILiquidSlot](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEISlot/JEILiquidSlot.md) | hasBase为是否渲染默认的流体槽（需对比宽高）                  |
| createLiquidSlot(isInput as bool, x as int, y as int, width as int, height as int, capacityMb as int, showCapacity as bool, @Optional(valueBoolean = true) hasBase as bool) | [JEILiquidSlot](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEISlot/JEILiquidSlot.md) | hasBase 同上, 但流体槽必须要根据固定的宽高创建 (eg：16 * 16, 43 * 16,  16 * 34) |
| createItemSlot(isInput as bool, x as int, y as int, @Optional(valueBoolean = true) hasBase as bool) | [JEIItemSlot](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEISlot/JEIItemSlot.md) | hasBase为是否渲染固定的物品槽                                |
| createJEIRecipe(uid as string)                               | [JEIRecipe](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIRecipe.md) | 创建JEI的配方，uid为定义JEI的uid                             |
| createJEIItemInputElement(x as int, y as int)                | [JEIItemElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEIItemElement.md) |                                                              |
| createJEIItemOutputElement(x as int, y as int)               | [JEIItemElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEIItemElement.md) |                                                              |
| createJEIFluidElement(x as int, y as int, width as int, height as int) | [JEIFluidElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEIFluidElement.md) |                                                              |
| createJEIFontInfoElement(x as int, y as int, info as string, color as int, @Optional width as int, @Optional height as int) | [JEIFontInfoElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEIFontInfoElement.md) |                                                              |
| createJEIArrowElement(x as int, y as int, direction as int)  | [JEIArrowElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEIArrowElement.md) | direction 参数为四个箭头，可填 0-3                           |
| createJEICustomElement(x as int, y as int, width as int, height as int, u as int, v as int, texture as string) | [JEICustomElement](https://github.com/ikexing-cn/RandomTweaker/blob/master/wiki/zh_cn/modSupport/JEI/JEIElement/JEICustomElement.md) | texture 的格式为 modid:路径                                  |

## 例子

```zenscript
import mods.jei.JEI;
import mods.randomtweaker.JEIPanel;

var keyJEI as JEIPanel = JEI.createJEIPanel("keys", "key");
keyJEI.setJEIBackGroup(JEI.createJEIBackground(150, 50));
keyJEI.addRecipeCatalyst(<minecraft:stone:3>);
keyJEI.addRecipeCatalyst(<minecraft:stone:1>);
keyJEI.addJEISlot(JEI.createItemSlot(true, 16, 18));
keyJEI.addJEISlot(JEI.createItemSlot(false, 80, 18));
keyJEI.addJEIElement(JEI.createJEIFontInfoElement(50, 18,  "font", 0x000000));
keyJEI.addJEIElement(JEI.createJEIFontInfoElement(100, 18, "fontInfo", 0x52575B));
keyJEI.register();

var keyJEI1 as JEIPanel = JEI.createJEIPanel("keys1", "key1");
keyJEI1.setJEIBackGroup(JEI.createJEIBackground(150, 50));
keyJEI1.addRecipeCatalyst(<minecraft:apple>);
keyJEI1.addRecipeCatalyst(<minecraft:stick>);
keyJEI1.addJEISlot(JEI.createItemSlot(true, 16, 18));
keyJEI1.addJEISlot(JEI.createItemSlot(false, 50, 18));
keyJEI1.addJEISlot(JEI.createLiquidSlot(true, 100, 18, 16, 34, 1000, false));
keyJEI1.onJEITooltip = function(mouseX, mouseY){
    var arr as string[] = ["test"];
    if (mouseX == 50 && mouseY == 50){
        return arr;
    }
};
keyJEI1.register();
```

repository: skyraah/RandomTweaker

repo_name: skyraah/RandomTweaker


text:
## Unable to install gems
i was unable to install gems due to permission error so solution was to install ruby 2.1.2 using [rvm](https://rvm.io/)
```bash
curl -sSL https://get.rvm.io | bash -s stable
rvm install 2.1.2
rvm use 2.1.2 --default
```

## method visibility
protected and private keywords work differently then other languages: so if you mark method to be private you can invoke it only using implicit invocation inside of this class methods:

```ruby
class Person
  def test
    hello #this works / implicit invocation
    self.hello #this doesn't work / explicit invocation
  end

  private
  def hello
    puts "hello there"
  end
end

person = Person.new
person.test
```

you can also invoke parent private methods implicitly in child class:

```ruby
class Parent
  private
  def hello
    puts "hello i am parent "
  end
end

class Child < Parent
  def test
    hello #this works / implicit invocation
    self.hello #this doesn't work / explicit invocation
  end
end

child = Child.new
child.test
```

protected keyword works same way but you can call it using implicit invocation and explicit invocation too.

you can't call private or protected methods outside of class:
```ruby
class Person
  protected
  def hello_protected
    puts "hello i am protected"
  end

  private
  def hello_private
    puts "hello i am private"
  end
end

child = Person.new
#both raises error
child.hello_protected
child.hello_private
```

### Differences between Procs and Lambdas
if we define both with arguments and call them,
proc will proceed and lambda will raise error.

```ruby

proc_test = proc { |text| puts "#{text} --- proc" }
lambda_test = lambda { |text| puts "#{text}  ---  lambda" }

proc_test.call() # this will work
lambda_test.call() # this will raise error, expected argument

```

if we return anything with proc and lambda , lambda'll work fine, but proc'll raise an error. thats because lambda always returns value and procs return doesn't refers to it's block, it refers to global context and in ruby we can't return anything in global context.
```ruby

proc_test = proc { return "proc test" }
lambda_test = lambda { return "lambda test" }

puts lambda_test.call # this will work fine
puts proc_test.call # this will raise error , unexpected return

```

repository: davit-khaburdzania/ruby-path

repo_name: davit-khaburdzania/ruby-path


text:
# Nikola Static Site Sample

> Nikola is a static site and blog generator, written in Python. It can use Mako and Jinja2
> templates, and input in many popular markup formats, such as reStructuredText and Markdown -
> and can even turn Jupyter (IPython) Notebooks into blog posts! It also supports image
> galleries, and is multilingual. Nikola is flexible, and page builds are extremely fast,
> courtesy of doit (which is rebuilding only what has been changed).
>
> -- getnikola.com

Shows how to use:

1. Pages
2. Posts
3. Custom Content Types (e.g. Bookmarks 'n' Links)

See the live version @ [`sites/nikola`](http://staystatic.github.io/sites/nikola)

```
|   conf.py
|
+---data/
|       links.yml
|
+---files/
|   \---css
|           style.css
|
+---posts/
|       new-build-system.md
|       new-repo-maps.md
|       new-season.md
|
+---stories/
|       about.md
|       index.md
|
\---templates/
    |   base.tmpl
    |   main_index.tmpl
    |   post_list_directive.tmpl
    |
    \---includes/
            footer.html
            github.html
            header.html
```

will result in:

```
|   index.html
|
+---about/
|       index.html
|
+---css/
|       style.css
|
\---posts/
    +---new-build-system/
    |       index.html
    |
    +---new-repo-maps/
    |       index.html
    |
    \---new-season/
            index.html
```

## Thanks

Contributed by [Roberto Alsina](https://github.com/ralsina). Thanks!

## Install & Build Notes

To install use:

```
$ pip install "nikola[extras]"
```

To build  use:

```
$ cd staystatic/nikola
$ nikola build
```

Find the compiled static site in the `output` folder.

## Todos

- [ ] in posts template add links to posts / news (now prev/next)
- [ ] clean up config - simplify - do NOT copy assets that will not get used etc.
  - [ ] do NOT generate blog archive
  - [ ] do NOT include source (why, why not??)
- [ ] configure to use "simple" non-pretty url/path e.g. about.html instead of about/index.html

repository: praneybehl/staystatic

repo_name: praneybehl/staystatic


text:
# Determine which genome build a gene set is coming from

Requirements:
 * Python 3
 * [snakemake](https://snakemake.readthedocs.io/en/stable/)

Installation:
 * clone the repo
 * `snakemake` will download reference genomes

Usage:
 * `python which_genome.py <path/to/cellranges/features.tsv.gz>`


text:
---
layout: post
title: "Symfony environment variables with Nginx and PHP-FPM"
excerpt: "It's a common thing to use environment variables to configure Symfony for dev, staging, production..."
tags: [Symfony, nginx, php-fpm, php, fpm, environment, env, variables, variable, var, apache]
image: symfony.gif
modified: "2020-04-09"
last_modified_at: "2020-04-09"
comments: true
---

It's [a common thing](http://symfony.com/doc/current/cookbook/configuration/external_parameters.html) to use environment variables to configure Symfony for dev, staging, production...
It allows to define specific configurations such as database host username and password, api entrypoint, ...
without saving those information into files and commiting them,... it's a bad practice and could lead to security problems.

![Symfony](/images/posts/symfony.gif)

## Apache

With Apache you can forward variables with this kind of configuration inside your host
(it supposes that environment variables are defined on your system) :

{% highlight bash %}

export SYMFONY__APP__SECRET="MY_SUPER_SECRET"
export SYMFONY__APP__PUBLIC="MY_SUPER_PUBLIC_KEY"
export SYMFONY__CRYPT__KEY="MY_SUPER_CRYPT_KEY"

<VirtualHost *:80>
    DocumentRoot /var/www/web

    SetEnv SYMFONY__APP__SECRET ${SYMFONY__APP__SECRET}
    SetEnv SYMFONY__APP__PUBLIC ${SYMFONY__APP__PUBLIC}
    SetEnv SYMFONY__CRYPT__KEY ${SYMFONY__CRYPT__KEY}

    ...
</VirtualHost>

{% endhighlight %}

It allows you to use Symfony through CLI or web pages and use the correct configurations.

## Nginx / PHP-FPM

With Nginx and more exactly with PHP-FPM, it's no so easy because of the default PHP-FPM configuration:

**\# clear_env boolean**

_Clear environment in FPM workers.
Prevents arbitrary environment variables from reaching FPM worker processes by clearing
the environment in workers before env vars specified in this pool configuration are added.
Since PHP 5.4.27, 5.5.11, and 5.6.0. Default value: Yes._

So by default all environment variables are cleared and not forwarded to PHP.

At this point, there are two ways to pass variables to your Symfony application,
both modifying the PHP-FPM pool config file `/etc/php5/fpm/pool.d/www.conf`
(could be a custom pool):

* Define all your env variables yourself at the end of the file:

{% highlight bash %}

env[SYMFONY__APP__SECRET] = $SYMFONY__APP__SECRET
env[SYMFONY__APP__PUBLIC] = $SYMFONY__APP__PUBLIC
env[SYMFONY__CRYPT__KEY] = $SYMFONY__CRYPT__KEY

{% endhighlight %}

* Modify the default value of the `clear_env` configuration to **No**
and you will have access to all env vars in your PHP application once php-fpm restarted.

{% highlight bash %}
;clear_env = no
...
clear_env = no
{% endhighlight %}

**Do not forget to remove the comma at the beginning of the line**

## Docker

If you use docker you could add this `RUN` command in your `Dockerfile` to change de default php-fpm configuration

{% highlight bash %}
RUN sed -e 's/;clear_env = no/clear_env = no/' -i /etc/php5/fpm/pool.d/www.conf
{% endhighlight %}

Rebuild your Docker image !!

## TIP

With Symfony production environment you will probably DO NOT have to forward those environment variables
in your virtual hosts files, because the cache is warmed up thanks to a CLI command... and... your variables
are probably already defined in your CLI/shell system:

* exports
* .bashrc/.zshrc
* docker/docker-compose environment variables

extension: markdown

gha_language: JavaScript

gha_license_id: MIT


text:
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# Compiler
 - Written in Java, Yacc and Flex

 - A joint work with [Erfan Sabouri](https://github.com/erfaansabouri)

 - This project is a C compiler that gets a C code and generated it’s equivalent Three-Address-Code using Yacc and Flex and the GUI is implemented in Java.

## License
This repository is released under [MIT License](https://opensource.org/licenses/MIT). To put it in a nutshell, This means that you can use the source codes in any opensource projects or contributions. Attribution is not mandatory but appreciated.

***To remove all barriers in the way of science.***

## FAQ
Your comments under any piece of the code is appreciated. I would be glad to answer any questions you may have over the codes and resources.

You can contact me via Gmail at : [hossein[dot]dehghanipour1998[at]gmail[dot]com](https://hossein.dehghanipour1998@gmail.com).

With regards,

Hossein Dehghanipour.


text:
# cq-ts-http
Only define your endpoints once. Use them in both clients and servers.

### docs
documentation of every package can be found [here](https://cq-ts.federicosordillo.com)

### examples
a working monorepo example can be found under the `/examples` foder.

### contibuting
just pick a card on the github projects found here, please be sure to follow `conventional-commits` guidelines.


text:
---
title: Compatibility argument matchers
layout: post
---

NSubstitute [argument matchers](/help/argument-matchers) depend on having C# 7.0 or later (as of NSubstitute 4.0). If you are stuck on an earlier version of C# you may get an error like the following when trying to use a matcher like `Arg.Is(123)`:

> `CS7085: By-reference return type 'ref T' is not supported.`

If you have C# 7.0-compatible tooling installed you can [set `<LangVersion />` in your test csproj file](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version) to `7` or higher, or to `latest` or `default`.

Stuck with pre-7.0 tooling? Then use `CompatArg` from the `NSubstitute.Compatibility` namespace instead of `Arg`. `CompatArg` will work everywhere `Arg` does, with the exception of matching `out` and `ref` args (which require C# 7.0 features). For example, if the documentation mentions `Arg.Is(42)`, you can instead use `CompatArg.Is(42)`.

## Using `CompatArg`

First, add `NSubstitute.Compatibility` to the list of imports:

    using NSubstitute;
    using NSubstitute.Compatibility;

Then use `CompatArg` in place of `Arg`:

{% requiredcode %}
public interface ICalculator {
    int Add(int a, int b);
}
ICalculator calculator;
[SetUp] public void SetUp() {
    calculator = Substitute.For<ICalculator>();
}
{% endrequiredcode %}

{% examplecode csharp %}
calculator.Add(1, -10);

// Instead of `Arg.Is<int>(x => x < 0)`, use:
calculator.Received().Add(1, CompatArg.Is<int>(x => x < 0));

// Instead of `Arg.Any<int>()`, use:
calculator
    .Received()
    .Add(1, CompatArg.Any<int>());

// Same for Returns and DidNotReceive:
calculator.Add(CompatArg.Any<int>(), CompatArg.Is(42)).Returns(123);
calculator.DidNotReceive().Add(CompatArg.Is<int>(x => x > 10), -10);
{% endexamplecode %}

To make this a bit less verbose you may want to create a wrapper within the root of your test project with a shorter name (e.g. `ArgC`) that delegates to `CompatArg`. This will also avoid needing the extra using import, and make it easier to switch to the standard `Arg` class once you're able to update to C# 7.0 and beyond.

repository: bakitorunoglu/NSubstitute

repo_name: bakitorunoglu/NSubstitute


text:
# gsub

gsub for the command-line, with find and sed

## prereq's

* [nodejs](http://nodejs.org/)
* [find](http://en.wikipedia.org/wiki/Find)
* [sed](http://en.wikipedia.org/wiki/Sed)

## installation

```bash
npm -g install gsub
```

## usage

```bash
gsub -n "*.js" sys util
```

See `gsub --help` for more info

## license

```plaintext
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```


text:
# ciutils plugin

[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-ciutils)
[![Build Status](https://img.shields.io/circleci/project/xfreebird/fastlane-plugin-ciutils/master.svg?style=flat)](https://circleci.com/gh/xfreebird/fastlane-plugin-ciutils)

## Getting Started

This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ciutils`, add it to your project by running:

```bash
bundle exec fastlane add_plugin ciutils
```

## About ciutils

Various utilities for CI and Xcode project configuration.

action                   |description
-------------------------|-------
`en_ci_utils_init`            | Initializes enviornment variables for **gym**, **scan**, **slather**, **oclint**, **swiftlint** and **lizard**.
 It forces all these actions to put all outputs to the **build** folder (e.g. derived data, logs, scan reports, slather reports, oclint report, lizard reports and swiftlint reports)
`en_setup_project` | Updates Xcode projects, Info.plist, Entitlements file and any other plist file using values from the provided yaml file [example `appstore.yml`](Demo/config/appstore.yml)
`en_create_sonar_reports` | Creates sonarqube reports (unit tests, code coverage, static code analysis with swiftlint, oclint and lizard) to be used with the open source sonarqube plugins for Swift and Objective-C
`en_build_number`    | Returns the value of current build number regardless of CI environment. If run on desktop, then is always `1`
`en_setup_keychain`  | Creates a keychain and if provided, it imports the give certificate file. It also updates **match** environment variables to use the new created keychain.
`en_remove_keychain` | Removes the keychain created by ```en_setup_keychain``` and restores the default keychain
`en_git_changelog`   | Creates the changelog based on git commits by filtering commit messages by a keyword
`en_close_simulator` | Quits the simulator
`en_install_provisioning_profiles` | Copies all provisioning profiles from project folder to `~/Library/MobileDevice/Provisioning Profiles`.
 Useful when signing certificates and provisioning profiles are managed directly from the Fastfile.
`en_profile_name`    | Returns the provisioning profile name by path or uuid

## Example

Check out the [example `Fastfile`](fastlane/Fastfile) and [project `FastlaneDemo`](Demo) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane build`.

## Run tests for this plugin

To run both the tests, and code style validation, run

```
rake
```

To automatically fix many of the styling issues, use
```
rubocop -a
```

## Issues and Feedback

For any other issues and feedback about this plugin, please submit it to this repository.

## Troubleshooting

If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.

## Using `fastlane` Plugins

For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).

## About `fastlane`

`fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).

repository: gugell/fastlane-plugin-ciutils

repo_name: gugell/fastlane-plugin-ciutils


text:
# Volatile read/write intrinsics

| Sectin         | Value                                                         |
|----------------|---------------------------------------------------------------|
| DIP:           | 20                                                            |
| Status:        | Implemented                                                   |
| Author:        | Alex Rønne Petersen (alex (AT) lycus.org)                     |
| Implementation:| <https://github.com/D-Programming-Language/druntime/pull/892> |

## Abstract

This document describes a couple of simple compiler intrinsics that D compilers
should implement. These are necessary for low-level, embedded, kernel, and
driver developers. These intrinsics will ensure that a compiler cannot reorder
volatile loads and stores with regards to each other.

### Links

* <https://issues.dlang.org/show_bug.cgi?id=13138>

## Description

Two intrinsics shall be declared in the core.bitop module.

The first one, volatileLoad is used to perform volatile read operations from memory:

``` D
T volatileLoad(T)(T* ptr);
```

A call to this function, such as:

``` D
T* p = ...;
T i = volatileLoad(p);
```

Shall be equivalent to:

``` D
T* p = ...;
T i = *p;
```

However, with the exception that the compiler is not allowed to optimize out
seemingly dead calls to volatileLoad, nor reorder calls to volatileLoad with
respect to other calls to it or volatileStore. The second, volatileStore is
used to perform volatile write operations to memory:

``` D
void volatileStore(T)(T* ptr, T val);
```

A call to this function, such as:

``` D
T* p = ...;
T i = ...;
volatileStore(p, i);
```

Shall be equivalent to:

``` D
T* p = ...;
T i = ...;
*p = i;
```

However, with the exception that the compiler is not allowed to optimize out
seemingly dead calls to volatileStore, nor reorder calls to volatileStore with
respect to other calls to it or volatileLoad.

### Detection

Compilers that support these intrinsics should define the D\_Volatile version
identifier. Compilers are free to support the intrinsics without defining this
version identifier, but programmers should not rely on the presence of the
intrinsics if it is not defined.

### Rationale

D currently has no way to do safe memory-mapped I/O. The reason for that is
that the language has no well-defined means to do volatile memory loads and
stores. This means that a compiler is free to reorder memory operations as it
sees fit and even erase some loads/stores that it thinks are dead (but which
have actual impact on program semantics).

These intrinsics will be essential for low-level development in D. D cannot
truly replace C and/or C++ until it can perform the same low-level operations
that developers who use those languages are accustomed to.

### Implementation

#### DMD

DMD does not currently reorder loads and stores, so no particular change needs
to happen in this area of the compiler. However, it is quite likely that the
back end eliminates dead loads and stores, so calls to the intrinsics must be
flagged as volatile in whatever way DMD's back end allows it.

#### GDC

GCC's internal code representation allows volatile statements in the C sense,
which is sufficient.

#### LDC

[LLVM trivially allows marking loads and stores as volatile](http://llvm.org/docs/LangRef.html#volatile)

#### Other compilers

Other compilers presumably have similar means to flag loads and stores as volatile.

### Alternatives

A number of alternatives to volatile intrinsics have been suggested. They are,
however, not good enough to actually replace a volatile intrinsics for the
reasons outlined below.

#### Shared qualifier

The shared type qualifier has been suggested as a solution to the problems
volatile intrinsics try to solve. However:

- It is not implemented in any compiler, so practically using it now is not
  possible at all.
- It does not have any well-defined semantics yet.
- It will most likely not be portable because it's designed for the x86
  memory model.
- If ever implemented, it will result in memory fences and/or atomic
  operations, which is \*\*not\*\* what volatile memory operations \* are
  about. This will severely affect pipelining and performance in general.

#### Inline assembly

It was suggested to use inline assembly to perform volatile memory operations. While a correct solution, it is not reasonable:

- It leads to unportable programs.
- It leads to a dependency on the compiler's inline assembly syntax.
- Some compilers may even decide to optimize the assembly itself.
- Memory-mapped I/O is too common in low-level programming for a systems
  language to require the programmer to drop to assembly.

## Copyright & License

Copyright (c) 2016 by the D Language Foundation

Licensed under [Creative Commons Zero 1.0](https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt)

repository: dlang/DIPs

gha_language: D

repo_name: dlang/DIPs


text:
# iExpense

![](images/demo.gif)

## Why @State only works with structs

@State is a property wrapper that monitors changes in our structs. Each time a value inside our struct changes the *whole* struct changes. We get a new struct every time.

There are two important differences between structs and classes:

- structs have unique owners
- classes can have multiple owners

With classes, multiple things can point to the same value. Classes are referenced based. Many have access to it's reference or pointer.

But structs are value based. There can be only one owner.

What that means is that if we have two SwiftUI views and we send them both the same struct to work with, they actually each have a unique copy of that struct; if one changes it, the other won't see that change. On the other hand, if we create an instance of a classes and send that to both views, they *will* share changes.

The reason why `@State` only works with structs is because when we change `@State` in a class, we aren't changing the reference of state. It remains the same.

Yes we are changing the values of state. But everyone gets the same value. No change.

With struct, because they are never shared, we do get a change in state. That's why @State only works in SwiftUI for structs.

If we want to share state change via a classes, we need something else. We need an `@ObservedObject`.

## Sharing state with @ObservedObject

If you want to use a class with your SwiftUI data - which you *will* want to do if that data should be shared across more than one view - then SwiftUI gives us two property wrappers that are useful:

- @ObserveredObject, and
- @EnvironmentObject

Let's now look at @ObservedObject. To make a SwiftUI class observable, we need to declare what is publishable.

```swift
class User {
    @Published var firstName = "Bilbo"
    @Published var lastName = "Baggins"
}
```

`@Published` is more or less half of `@State`. It tells Swift that whenever either of those two properties change, it should send an announcement out to any SwiftUI views that are watching that they should reload.

How do those views know which classes might send out these modifications? That's another property wrapper, `@ObservedObject`. Which is the other half of `@State`. it tells SwiftUI to watch a class for any change annoucements.

```swift
@ObservedObject var user = User()
```

So really to make something observable we go from this:

```swift
struct User {
    var firstName = "Bilbo"
    var lastName = "Baggins"
}

struct ContentView: View {
    @State private var user = User()
```

To this:

```swift
class User: ObservableObject {
    @Published var firstName = "Bilbo"
    @Published var lastName = "Baggins"
}

struct ContentView: View {
    @ObservedObject var user = User()
```

The end result here is that we can have our state stored in an exeternal object, and we can now use that object in multiple views and have them all point to the same values.

## Showing and hiding views

There are several ways of showing views in SwiftUI, and one of the most basic is a sheet: a new view presented on top of our existing one. On iOS this automatically gives us a card-like presentation where the current view slides away into the distance a little and the new view animates in on top.

Sheets work much like alerts, in that we don’t present them directly with code such as `mySheet.present()` or similar. Instead, we define the conditions under which a sheet should be shown, and when those conditions become true or false the sheet will either be presented or dismissed respectively.

Let’s start with a simple example, which will be showing one view from another using a sheet. First, we create the view we want to show inside a sheet, like this:

```swift
struct SecondView: View {
    var body: some View {
        Text("Second View")
    }
}

struct ContentView: View {
    @State private var showingSheet = false

    var body: some View {
        Button("Show Sheet") {
            self.showingSheet.toggle()
        }
        .sheet(isPresented: $showingSheet) {
            SecondView()
        }
    }
}
```

![](images/1.gif)

First we defined some state to track if the sheet is showing.

```swift
@State private var showingSheet = false
```

Then we toggle that state in the button.

```swift
self.showingSheet.toggle()
```

Then the magic to make the new sheet appear is here.

```swift
.sheet(isPresented: $showingSheet) {
    // contents of the sheet
}
```

This is a two-way binding to our state property. It fires when `$showingSheet` changes.

### Passing data

You can pass information to another view by defining a var in the view.

```swift
struct SecondView: View {
    var name: String

    var body: some View {
        Text("Hello, \(name)!")
    }
}
```

And then passing it to the view when constructed.

```swift
.sheet(isPresented: $showingSheet) {
    SecondView(name: "@twostraws")
}
```

### Dismissing the view

The user can dismiss the view by swiping downwards. But let's look at how to make the view disappear programmatically.

We could use a @State property wrapper. Another is to use an @Environment.

@Environment allows us to provide data to other views externally. We can read our views presentation mode from the environment.

To try it out add this property to the second view.

```swift
@Environment(\.presentationMode) var presentationMode
```

The presentation mode of a view contains only two pieces of data, but both are useful: a property storing whether the view is currently presented on screen, and a method to let us dismiss the view immediately.

```swift
struct SecondView: View {
    @Environment(\.presentationMode) var presentationMode

    var name: String

    var body: some View {
        Button("Dismiss") {
            presentationMode.wrappedValue.dismiss()
        }
    }
}

struct ContentView: View {
    @State private var showingSheet = false

    var body: some View {
        Button("Show Sheet") {
            self.showingSheet.toggle()
        }
        .sheet(isPresented: $showingSheet) {
            SecondView(name: "Tron")
        }
    }
}
```

![](images/2.gif)

## Working with Identifiable items in SwiftUI

When we create static views (VStack, TextField, Button) SwiftUI can see exactly which views we have and is able to control and animate them and so on.

When we use `List` and `ForEach` to make dynamic views, SwiftUI needs to know how it can identify each item uniquely. Otherwise it's not able to compare view hierarchies and keep track of what has changed.

That's why we need whatever it is we are adding to our `List` or `ForEach` to by uniquely identifiable. We can do this using the `Identifiable` protocol which simply makes our structs require a property `id`.

```swift
struct ExpenseItem: Identifiable {
    let id = UUID()
    let name: String
    let type: String
    let amount: Int
}
```

And then use it like this.

```swift
ForEach(expenses.items) { item in
    Text(item.name)
}
```

## Full source

**ContentView.swift**

```swift
//
//  ContentView.swift
//  iExpense
//
//  Created by jrasmusson on 2021-05-02.
//

import SwiftUI

struct ExpenseItem: Identifiable, Codable {
    let id = UUID()
    let name: String
    let type: String
    let amount: Int
}

class Expenses: ObservableObject {
    @Published var items = [ExpenseItem]() {
        didSet {
            let encoder = JSONEncoder()
            if let encoded = try? encoder.encode(items) {
                UserDefaults.standard.set(encoded, forKey: "Items")
            }
        }
    }

    init() {
        if let items = UserDefaults.standard.data(forKey: "Items") {
            let decoder = JSONDecoder()
            if let decoded = try? decoder.decode([ExpenseItem].self, from: items) {
                self.items = decoded
                return
            }
        }

        self.items = []
    }
}

struct ContentView: View {
    @State private var numbers = [Int]()
    @State private var currentNumber = 1
    @State private var showingAddExpense = false

    @ObservedObject var expenses = Expenses()

    var body: some View {

        NavigationView {
            List {
                ForEach(expenses.items) { item in
                    HStack {
                        VStack(alignment: .leading) {
                            Text(item.name)
                                .font(.headline)
                            Text(item.type)
                        }

                        Spacer()
                        Text("$\(item.amount)")
                    }
                }
                .onDelete(perform: removeItems)
            }
            .navigationBarItems(trailing:
                Button(action: {
                    self.showingAddExpense = true
                }) {
                    Image(systemName: "plus")
                }
            )
        }.sheet(isPresented: $showingAddExpense) {
            AddView(expenses: self.expenses)
        }

    }

    func removeItems(at offsets: IndexSet) {
        expenses.items.remove(atOffsets: offsets)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
```

**AddView.swift**

```swift
//
//  AddView.swift
//  iExpense
//
//  Created by jrasmusson on 2021-05-04.
//

import SwiftUI

struct AddView: View {
    @State private var name = ""
    @State private var type = "Personal"
    @State private var amount = ""

    @ObservedObject var expenses: Expenses

    // No type required here - Swift can figure out
    @Environment(\.presentationMode) var presentationMode

    static let types = ["Business", "Personal"]

    var body: some View {
        NavigationView {
            Form {
                TextField("Name", text: $name)
                Picker("Type", selection: $type) {
                    ForEach(Self.types, id: \.self) {
                        Text($0)
                    }
                }
                TextField("Amount", text: $amount)
                    .keyboardType(.numberPad)
            }
            .navigationBarTitle("Add new expense")
            .navigationBarItems(trailing: Button("Save") {
                if let actualAmount = Int(self.amount) {
                    let item = ExpenseItem(name: self.name, type: self.type, amount: actualAmount)
                    self.expenses.items.append(item)
                }
                self.presentationMode.wrappedValue.dismiss()
            }
            )
        }
    }
}

struct AddView_Previews: PreviewProvider {
    static var previews: some View {
        AddView(expenses: Expenses())
    }
}
```

### Links that help

- [iExpense Intro](https://www.hackingwithswift.com/books/ios-swiftui/iexpense-introduction)
- [Why state only works with structs](https://www.hackingwithswift.com/books/ios-swiftui/why-state-only-works-with-structs)
- [Sharing SwiftUI state with @ObservedObject](https://www.hackingwithswift.com/books/ios-swiftui/sharing-swiftui-state-with-observedobject)
- [Showing and hiding views](https://www.hackingwithswift.com/books/ios-swiftui/showing-and-hiding-views)
- [Working with Identifiable items in SwiftUI](https://www.hackingwithswift.com/books/ios-swiftui/working-with-identifiable-items-in-swiftui)

repository: SwiftyJanek/swiftui

branch_name: refs/heads/main

repo_name: SwiftyJanek/swiftui


text:
---
layout: post
title:  "Day 15: Lex Scanner"
color:  teal
width:   6
height:  1
date:   2017-09-12 23:00:00 -0700
categories: c compilers
---

I've been incredibly busy with schoolwork this week, so today was another "Coding for
  School" day of this challenge. It's a little less exciting that way, but I still
  learn a ton from my hands-on class projects!

In my Compilers class, we're finally getting out hands dirty on some real compiler code;
  today, I wrote a Lex scanner to practice identifying tokens from an input file based
  on pattern-matching via regular expressions.

The project was relatively straightforward, though multi-line comments (think /*
  ... \*\/ if you're familiar with C) threw me for a bit of a loop. I had it working
  with an online regex tester using a lookahead approach, but I could only get it
  working in the Lex scanner using Start Conditions.

Unfortunately, I can't share my code here as it would violate my school's Code of Academic
  Integrity to share it publicly. I committed it to a private repo on GitHub to make
  sure I tracked today's commits!


text:
# Recipe 11.3, Understanding Mutable Variables with Immutable Collections

(These are a few notes from this recipe.)

For instance, when you create a `var` field with an immutable `Vector`, it appears you can somehow add new elements to the `Vector`:

```scala
var x = Vector(1)     // x: Vector(1)
x = x :+ 2            // x: Vector(1, 2)
x = x ++ List(3, 4)   // x: Vector(1, 2, 3, 4)
```

The end result is similar to these lines of code:

```scala
var x = Vector(1)
x = Vector(1, 2)         // reassign x
x = Vector(1, 2, 3, 4)   // reassign x again
```


text:
# Guzzle Services

[![License](https://poser.pugx.org/guzzlehttp/guzzle-services/license)](https://packagist.org/packages/guzzlehttp/guzzle-services)
[![Build Status](https://travis-ci.org/guzzle/guzzle-services.svg?branch=master)](https://travis-ci.org/guzzle/guzzle-services)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/guzzle/guzzle-services/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/guzzle/guzzle-services/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/guzzle/guzzle-services/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/guzzle/guzzle-services/?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/b08be676-b209-40b7-a6df-b6d13e8dff62/mini.png)](https://insight.sensiolabs.com/projects/b08be676-b209-40b7-a6df-b6d13e8dff62)
[![Latest Stable Version](https://poser.pugx.org/guzzlehttp/guzzle-services/v/stable)](https://packagist.org/packages/guzzlehttp/guzzle-services)
[![Latest Unstable Version](https://poser.pugx.org/guzzlehttp/guzzle-services/v/unstable)](https://packagist.org/packages/guzzlehttp/guzzle-services)
[![Total Downloads](https://poser.pugx.org/guzzlehttp/guzzle-services/downloads)](https://packagist.org/packages/guzzlehttp/guzzle-services)

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

```php
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Command\Guzzle\Description;

$client = new Client();
$description = new Description([
	'baseUri' => 'http://httpbin.org/',
	'operations' => [
		'testing' => [
			'httpMethod' => 'GET',
			'uri' => '/get{?foo}',
			'responseModel' => 'getResponse',
			'parameters' => [
				'foo' => [
					'type' => 'string',
					'location' => 'uri'
				],
				'bar' => [
					'type' => 'string',
					'location' => 'query'
				]
			]
		]
	],
	'models' => [
		'getResponse' => [
			'type' => 'object',
			'additionalProperties' => [
				'location' => 'json'
			]
		]
	]
]);

$guzzleClient = new GuzzleClient($client, $description);

$result = $guzzleClient->testing(['foo' => 'bar']);
echo $result['args']['foo'];
// bar
```

## Installing

This project can be installed using Composer:

``composer require guzzlehttp/guzzle-services``

For **Guzzle 5**, use ``composer require guzzlehttp/guzzle-services:0.6``.

**Note:** If Composer is not installed [globally](https://getcomposer.org/doc/00-intro.md#globally) then you may need to run the preceding Composer commands using ``php composer.phar`` (where ``composer.phar`` is the path to your copy of Composer), instead of just ``composer``.

## Plugins

* Load Service description from file [https://github.com/gimler/guzzle-description-loader]

## Transition guide from Guzzle 5.0 to 6.0

### Change regarding PostField and PostFile

The request locations `postField` and `postFile` were removed in favor of `formParam` and `multipart`. If your description looks like

```php
[
    'baseUri' => 'http://httpbin.org/',
    'operations' => [
        'testing' => [
            'httpMethod' => 'GET',
            'uri' => '/get{?foo}',
            'responseModel' => 'getResponse',
            'parameters' => [
                'foo' => [
                    'type' => 'string',
                    'location' => 'postField'
                ],
                'bar' => [
                    'type' => 'string',
                    'location' => 'postFile'
                ]
            ]
        ]
    ],
]
```

you need to change `postField` to `formParam` and `postFile` to `multipart`.

More documentation coming soon.

## Cookbook

### Changing the way query params are serialized

By default, query params are serialized using strict RFC3986 rules, using `http_build_query` method. With this, array params are serialized this way:

```php
$client->myMethod(['foo' => ['bar', 'baz']]);

// Query params will be foo[0]=bar&foo[1]=baz
```

However, a lot of APIs in the wild require the numeric indices to be removed, so that the query params end up being `foo[]=bar&foo[]=baz`. You
can easily change the behaviour by creating your own serializer and overriding the "query" request location:

```php
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation;
use GuzzleHttp\Command\Guzzle\QuerySerializer\Rfc3986Serializer;
use GuzzleHttp\Command\Guzzle\Serializer;

$queryLocation   = new QueryLocation('query', new Rfc3986Serializer(true));
$serializer      = new Serializer($description, ['query' => $queryLocation]);
$guzzleClient    = new GuzzleClient($client, $description, $serializer);
```

You can also create your own serializer if you have specific needs.

repository: xiebruce/PicUploader

gha_language: PHP

repo_name: xiebruce/PicUploader


text:
Practice problems

🎓 random practice problems

## Tree

- [03-level-order-traversal.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/03-level-order-traversal.js) - 2020-11-26
- [02-traversal.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/02-traversal.js) - 2020-11-26
- [04-same-tree.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/04-same-tree.js) - 2020-11-26
- [01-size-of-the-tree.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/01-size-of-the-tree.js) - 2020-11-26
- [05-mirror-of-tree.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/05-mirror-of-tree.js) - 2020-12-05
- [06-spiral-level-traversal.js](https://github.com/ashishdotme/practice-problems/blob/master/tree/06-spiral-level-traversal.js) - 2020-12-05

## Dp

- [01-maximum-sub-array.js](https://github.com/ashishdotme/practice-problems/blob/master/dp/01-maximum-sub-array.js) - 2020-12-15
- [02-longest-increasing-subsequence.js](https://github.com/ashishdotme/practice-problems/blob/master/dp/02-longest-increasing-subsequence.js) - 2020-12-15
- [05-edit-distance.js](https://github.com/ashishdotme/practice-problems/blob/master/dp/05-edit-distance.js) - 2020-12-15
- [04-bitonic-sequence.js](https://github.com/ashishdotme/practice-problems/blob/master/dp/04-bitonic-sequence.js) - 2020-12-15
- [03-longest-decreasing-subsequence.js](https://github.com/ashishdotme/practice-problems/blob/master/dp/03-longest-decreasing-subsequence.js) - 2020-12-15


text:
# pivotal-tracker

A Clojure library for interacting with the Pivotal Tracker API (v3)

## Installation

Clojars? I haven't actually released it yet.

## Usage

### Require It

```clojure
(ns my-app.core
  (:require [pivotal-tracker.client :as client]))
```

### List of Projects

```clojure
(client/projects "APITOKEN")
```

### Specific Project (by ID)

```clojure
(client/project "APITOKEN" 12345)
```

### List of Stories (by Project ID)

```clojure
(client/stories "APITOKEN" 12345)
```

With filtering parameters

```clojure
(client/stories "APITOKEN" 12345 {:filter "state:started"})
```

## License

Copyright © 2013 Andy Lindeman

Distributed under the MIT License.

repository: alindeman/pivotal-tracker

repo_name: alindeman/pivotal-tracker


text:
---
title: web-fwk-layer-community
tags: [community, layer, web]
created: 2021-08-15T16:49:15.428Z
modified: 2021-08-15T16:49:35.180Z
---

# web-fwk-layer-community

# guide

- [uber base design: Layers/LayersManager/Tether](https://baseweb.design/components/layer/)
# discuss
- ## Anyone has links for inspiration about how component libraries approach z-index?
- https://twitter.com/blvdmitry/status/1426915191552413707
  - Especially cases when a component might be above and below another component at the same time.
  - For instance, sticky header that goes over opened dropdowns on the page but also has a dropdown in it
- I like to have a zIndices object with keys for certain things. Makes it easier to shift stuff around, and see all the custom indexes in one place.
  - Absolutely. I also have one but store it on the css variables side instead to keep it working with any css framework.


text:
---
title: Down the rabbit hole of styling in React
date: 2018-04-25
published: true
tags:
  - react
  - css
  - javascript
---
React has left the question of styling mostly unanswered. Since we are basically making HTML apps for the browser, it goes without saying that CSS will have to be the technology of choice. Yet the basic premise of Cascading Style Sheets seems to othogonal to the philosophy behind React. First, the cascading nature of CSS has little bearing on the atomic React components. Secondly, inheritence is a key feature of CSS, where React is built on the opposite paradigm of composition. Finally, CSS thrives through separation of concerns, where it is decoupled from the HTML, while React advocates tightly coupled JS, HTML (and CSS?).

While this may all hold true, React does offer its own possibilities of solving the issue. The react code is run through a compiler before deployment. This process is highly configurable and typically splits out the javascript into a separate bundle. That's something that could have use for CSS as well.

# A list of solutions

There are unanswered questions and lots of personal preferences, that have resulted in various solutions with their own following. They do not cover exactly the same needs and some can even be used in parrellel. Here is a list of solutions I explored in varying degrees of depth:
+ Atomic / functional CSS
+ CSS-modules
+ Styled components
+ JSS
+ Typography.js
+ Glamorous
+ Emotion

## Atomic / functional CSS

Atomic CSS reject the semantic and cascading nature of CSS altogether. They propose a "functional" style of CSS without any side-effects and the lowest possible specificity. Notable examples are [Tachyons]() and [ACSS](). The class names typically describe a single style they apply to the element, such as `pr-2` for "padding right, scale 2". There is a substantial stylesheet that tries to cover as many use cases as possible. In a React application, you would apply the classes almost as you would apply inline styles. Without some of the drawbacks: the styles can be cached in a separate CSS file. It's a bit of an anti-solution to the problem of integrating CSS in Javascript, in that it denies that there should be any connection. There are some advantages to this approach:
+ It's viable beyond React apps, and can be used for any project, simply being a CSS file.
+ In a perfect scenario, the default CSS file covers all your needs. What's more, you can use a cached version so it really becomes a fast solution.
+ All the information is right there with the element.
+ Eliminates the need to come up with semantic class names.

Then there are some distinct drawbacks.
+ The supplied default CSS cannot have everything covered: certainly in a world with pseudo selectors, the number of conceivable styles balloons rapidly. That leaves a choice between a large CSS file or lots of edge cases.
+ This brings us to the next issue: there is no solution beyond its limits. Are we going to use traditional CSS to cover for that?
+ Elements often get a long list of classes and the readability leaves to be desired.
+ A solution is needed for consistency in the design, which will often come down to the re-use of a number of classes. This can be stored in a variable of react or your templating language. Will we make this semantic? Are we back to square one?

## CSS Modules

CSS Modules is mainly pre-occupied with solving the scoping problem, not unlike the BEM convention exists in conventional CSS. The CSS is scoped to react components, but there is also basic support for theming. The CSS is still just CSS and is imported from a separate file into your React component.

```javascript
import styles from "./style.css";
// import { className } from "./style.css";

element.innerHTML = '<div class="' + styles.className + '">';
```

# CSS in JS solutions

CSS-in-JS is at heart a very simple process.
+ You give me styles.
+ I hash the content.
+ I create a CSS Rule(s) using the hash as the class name.
+ I put those Rule(s) into a stylesheet that exists somewhere in the DOM.

This stylesheet uses the exact set of APIs that writing some CSS styles in an inline style tag and inserting it into the DOM would do.

## JSS

With JSS you define the styles in a javscript object. The styles are made available to the `className` property of elements. The JSS library converts the javascript styles to a CSS document and auto-generates names for the classes.

```javascript
// app.js
import injectSheet from 'react-jss';

const styles = {
  container: {
    margin: '0 auto',
    width: '100%',
    '@media screen and (min-width: 360px)': {
      maxWidth: '400px',
    },
    '@media screen and (min-width: 600px)': {
      maxWidth: '600px',
    },
  },
};

const App = (props) => (
  <div className={props.sheet.classes.container}>
    <Tweet data={data} />
  </div>
);

export default injectSheet(styles)(App);
```

There is limited support for theming.

## Typography.js

The [typography.js](http://kyleamathews.github.io/typography.js/) library has a different scope than the other solutions here. It's concerned with creating a project-wide typography and not so much with styling individual components (although these may inherit the global typography). Thereby it presents a quick and unobtrusive way to uniformely style your app.

The themes are simply collections of styles in a javscript object (somewhat like JSS). This shows how to apply and modify a theme:

```
import Typography from 'typography'
import funstonTheme from 'typography-theme-funston'
funstonTheme.baseFontSize = '22px' // was 20px.

const typography = new Typography(funstonTheme)
```

Addional styling rules can be added through plugins. It's still a pretty young project but looks promising and plays well with solutions that aim more at styling individual components.

## Styled components

With styled components, you really write css-in-js. It does take a bit more of a mental step than CSS Modules.

```javascript
import React from 'react';

import styled from 'styled-components';

// Create a <Title> react component that renders an <h1> which is
// centered, palevioletred and sized at 1.5em
const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

// Use them like any other React component – except they're styled!
<div>
  <Title>Hello World, this is my first styled component!</Title>
</div>
```
It is tightly coupled with React, and works in React Native as well.

## Glamorous and Emotion

Glamorous and Emotion have a lot in common with each other and with Styled Components. Glamorous opts for javascript objects instead of tagged template literals. Emotion actually supports both. It makes sense to offer a choice as both have their strengths: template literals can be closer to actual CSS, while javascript objects have powerful language features for manipulation.

Emotion claims a small footprint and fast performance. Somthing I have not yet put to the test. Both have good support for theming and both have a lively community. Can't wait to see if Emotion lives up to its promises.

# My thoughts

The solutions that were explorered deviate increasingly from the tradional use of CSS. Some of the strengths of CSS may be lost along the way (cascading nature), while I am not yet clear on what is gained in terms of customization, theming and composition to make up for that. The last few solutions are tightly coupled to react-style javascript frameworks, which should also be a consideration when chosing a tool.

I will make a deep dive with Emotion and Typography.js for an upcoming project and report back on my findings.