Blog

  • crashlytics-sample

    Crashlytics and Timber combinations


    This project shows how to set up Firebase Crashlytics with the awesome logger API Timber

    Features

    • Get crash reports
    • Get non-fatal errors into Firebase Crashlytics dashboard in an easy way with Timber
    • Disable sending the reports to Firebase Crashlytics in DEBUG mode

    How to setup

    implementation 'com.jakewharton.timber:timber:4.7.1'
    
    • Add a custom Timber.Tree

    class CrashlyticsTree : Timber.Tree() {
    
     private val KEY_PRIORITY = "priority"
     private val KEY_TAG = "tag"
     private val KEY_MESSAGE = "message"
    
     override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
          when (priority) {
             Log.VERBOSE, Log.DEBUG, Log.INFO -> return
    
             else -> {
                 Crashlytics.setInt(KEY_PRIORITY, priority)
      				Crashlytics.setString(KEY_TAG, tag)
    				Crashlytics.setString(KEY_MESSAGE, message)
    
    				if (t == null) {
    					Crashlytics.logException(Exception(message))
     				} else {
    					Crashlytics.logException(t)
    				}
    			}
    		}
    	}
    • Install and integrate Firebase Crashlytics with Timber in your Application class

    val crashlytics = CrashlyticsCore.Builder()
                    .disabled(BuildConfig.DEBUG)
                    .build()
    Fabric.with(this, Crashlytics.Builder().core(crashlytics).build())
    
     if (BuildConfig.DEBUG) {
     	Timber.plant(Timber.DebugTree())
     }
     Timber.plant(CrashlyticsTree())

    see more at App.kt

    How to use

    • A crash will be reported automatically
    • Logs a non-fatal via Timber.e() or Timber.w()

    Credit

    Visit original content creator repository
    https://github.com/thuongleit/crashlytics-sample

  • finegan

    FineGAN

    Pytorch implementation for learning to synthesize images in a hierarchical, stagewise manner by disentangling background, object shape and object appearance.

    FineGAN: Unsupervised Hierarchical Disentanglement for Fine-grained Object Generation and Discovery

    Krishna Kumar Singh*, Utkarsh Ojha*, Yong Jae Lee
    project | arxiv | demo video | talk video
    CVPR 2019 (Oral Presentation)

    Architecture


    Requirements

    • Linux
    • Python 2.7
    • Pytorch 0.4.1
    • TensorboardX 1.2
    • NVIDIA GPU + CUDA CuDNN

    Getting started

    Clone the repository

    git clone https://github.com/kkanshul/finegan
    cd finegan

    Setting up the data

    Note: You only need to download the data if you wish to train your own model.

    Download the formatted CUB data from this link and extract it inside the data directory

    cd data
    unzip birds.zip
    cd ..

    Downloading pretrained models

    Pretrained generator models for CUB, Stanford Dogs are available at this link. Download and extract them in the models directory.

    cd models
    unzip netG.zip
    cd ../code/

    Evaluating the model

    In cfg/eval.yml:

    • Specify the model path in TRAIN.NET_G.
    • Specify the output directory to save the generated images in SAVE_DIR.
    • Specify the number of super and fine-grained categories in SUPER_CATEGORIES and FINE_GRAINED_CATEGORIES according to our paper.
    • Specify the option for using ‘tied’ latent codes in TIED_CODES:
      • if True, specify the child code in TEST_CHILD_CLASS. The background and parent codes are derived through the child code in this case.
      • if False, i.e. no relationship between parent, child or background code, specify each of them in TEST_PARENT_CLASS, TEST_CHILD_CLASS and TEST_BACKGROUND_CLASS respectively.
    • Run python main.py --cfg cfg/eval.yml --gpu 0

    Training your own model

    In cfg/train.yml:

    • Specify the dataset location in DATA_DIR.
      • NOTE: If you wish to train this on your own (different) dataset, please make sure it is formatted in a way similar to the CUB dataset that we’ve provided.
    • Specify the number of super and fine-grained categories that you wish for FineGAN to discover, in SUPER_CATEGORIES and FINE_GRAINED_CATEGORIES.
    • Specify the training hyperparameters in TRAIN.
    • Run python main.py --cfg cfg/train.yml --gpu 0

    Sample generation results of FineGAN

    1. Stage wise image generation results

    2. Grouping among the generated images (child).

    Citation

    If you find this code useful in your research, consider citing our work:

    @inproceedings{singh-cvpr2019,
      title = {FineGAN: Unsupervised Hierarchical Disentanglement for Fine-Grained Object Generation and Discovery},
      author = {Krishna Kumar Singh and Utkarsh Ojha and Yong Jae Lee},
      booktitle = {CVPR},
      year = {2019}
    }
    

    Acknowledgement

    We thank the authors of StackGAN++: Realistic Image Synthesis with Stacked Generative Adversarial Networks for releasing their source code.

    Contact

    For any questions regarding our paper or code, contact Krishna Kumar Singh and Utkarsh Ojha.

    Visit original content creator repository https://github.com/kkanshul/finegan
  • snake

    A Multi-Player Snake game in sdl

    ScreenShots

    menu game multiplayer paused game over

    build dependancies

    • wxWidgets
    • SDL2
    • SDL2_image
    • SDL2_ttf
    • SDL2_mixer
    • cmake
    • git

    Building in linux

    git clone github.com/SL-Pirate/snake
    cd snake
    mkdir build
    cd build
    cmake ..
    make

    To Run the program

    do sudo chmod +x ./snake

    • This needs to be done only once!
    • after this is done just execute the snake binary from a command line or a graphical file manager.

    Building for windows

    Setting up building environment for windows

    1. Download and install wxWidgets from their official website

    2. Add the path_to_the_root_of_your_wxWidgets_folder to your system environment variables under the name wxWidgets

    3. Download the development packages of

      • SDL2
      • SDL2_image
      • SDL2_ttf
      • SDL2_mixer

      corresponding to your compiler

    4. Extract the development package of SDL2 and rename the directory as SDL2

    5. Extract the development package of SDL2_image to the same folder and rename it as SDL2_image

    6. Extract the development package of SDL2_image to the same folder and rename it as SDL2_ttf

    7. Extract the development package of SDL2_mixer to the same folder and rename it as SDL2_mixer

      Now your directory should look like this

      {BaseFolder}
      ├── SDL2
          ├── cmake
          ├── include
          ├── lib
          etc...
      .......
          SDL2_image
          ├── cmake
          ├── include
          ├── lib
          etc...
      ........
          SDL2_ttf
          ├── cmake
          ├── include
          ├── lib
          etc...
      ........
          SDL2_mixer
          ├── cmake
          ├── include
          ├── lib
          etc...
      
    8. Add the path_to_the_root_of_your_SDL2_BaseFolder to your system environment variables under the name SDL2

    Compiling

    • if using MinGW32-gcc
    git clone github.com/SL-Pirate/snake
    cd snake
    mkdir build
    cd build
    cmake .. -G "MinGW Makefiles"
    make
    • if using msvc
    git clone github.com/SL-Pirate/snake
    cd snake
    mkdir build
    cd build
    cmake --build ..
    Visit original content creator repository https://github.com/SL-Pirate/snake
  • hsfuck

    hsfuck

    Tests CI Build CI License

    Logo

    A brainfuck compiler written in Haskell

    Tech stack

    • Languages: Haskell
    • Packages: Parsec

    Blog Post

    I wrote a blog post about this project

    How to install and use

    You need to have cabal, Haskell installed. Then run the following commands To run the program you need gcc for the C version and SPIM for the MIPS version

    # clone the repo and move to it
    git clone https://github.com/tttardigrado/hsfuck
    cd hsfuck
    
    # build the project using cabal
    cabal build
    
    # optionally move the binary into another location with
    # cp ./path/to/binary .
    
    # run the compiler
    # (fst argument is compilation target mode. Either c or mips)
    # (snd argument is the path of the src file)
    # (trd argument is the path of the output file)
    ./hsfuck c test.bf test.c
    
    # compile and run the C code
    gcc test.c
    ./a.out

    Suggestion: Add the following snippets to your .bashrc

    # compile brainfuck to c and then to binary
    bfC()
    {
        ./hsfuck c $1 /tmp/ccode.c
        gcc /tmp/ccode.c -o $2
    }
    # simulate as MIPS (using SPIM)
    bfMIPS()
    {
        ./hsfuck mips $1 /tmp/mipscode.mips
        spim -file /tmp/mipscode.mips
    }

    Commands

    • + increment the value of the current cell
    • - decrement the value of the current cell
    • » right shift the value of the current cell
    • « left shift the value of the current cell
    • > move the tape one cell to the right
    • < move the tape one cell to the left
    • . print the value of the current cell as ASCII
    • , read the value of an ASCII character from stdin to the current cell
    • : print the value of the current cell as an integer
    • ; read an integer from stdin to the current cell
    • [c] execute c while the value of the cell is not zero
    • # print debug information

    References

    TO DO:

    • 0 set the cell to 0
    • » and « -> right and left shifts
    • Add more print and read options (integer)
    • remove register
    • compile to MIPS
    • Add debug to MIPS target
    • Test MIPS and C output
    • Add compilation target flag
    • Add commands documentation
    • Add references
    Visit original content creator repository https://github.com/tttardigrado/hsfuck
  • iBET

    iBET – interactive Bioinformatics Exploratory Tools

    Generating static reports from R markdown documents is a common way to distribute bioinformatics analyses with additional context and commentary. However, interactivity within these reports is limited. While one can embed minimally interactive figures in HTML reports, there is no way to alter the underlying data or plot by the end user.

    Shiny provides an avenue to overcome this limitation, as Shiny widgets can be designed to interactively perform or display the results of an analysis. This comes with the downside that the Rmd file and necessary code must be hosted on a server that can run Shiny applications and interactive documents. Options include RStudio Connect, shiny.apps.io (which has a free tier), and Shiny Server.

    iBET (interactive Bioinformatics Exploratory Tools) is an R package that contains drop-in Shiny widgets that run and/or display the results of common analyses performed with bioinformatics R packages. These empower end-users to fully immerse themselves in the data through interactive alterations of plot and analysis parameters. They are excellent tools for collaborative data wading and exploration and function well both as stand-alone apps or within Rmd files hosted on Shiny Servers.

    Installation

    This package is in development – it may break at any time and contain unstable or untested features. A stable version will be submitted to CRAN or Bioconductor once the initially planned features are completed.

    To install the package via Github:

    install.packages("devtools")
    devtools::install_github("j-andrews7/iBET")
    

    Usage

    iBET currently contains three interactive widgets – shinyPCAtools, shinyDESeq2, and shinyDECorr. They can be dropped into Rmd documents or ran directly within RStudio as shown below.

    I highly recommend altering the width of your Rmd report by using a CSS block at the top of your document (right after the YAML header). This will use much more of the page, which makes using the widgets much easier. The following works well on most screens with no scaling:

    ```{css, echo=FALSE}
    body {
      max-width: 1850px !important;
    }
    div.main-container {
      max-width: 1850px !important;
      width: 1850px !important;
      margin-left: auto !important;
      margin-right: auto !important;
    }
    .toc-content {
      padding-right: 0px;
      padding-left: 0px;
      margin-left: 300px;
      max-width: 1550px !important;
      width: 1550px !important;
    }
    
    

    Load Example Data

    shh <- suppressPackageStartupMessages
    shh(library("airway"))
    shh(library("magrittr"))
    shh(library("DESeq2"))
    shh(library("PCAtools"))
    shh(library("iBET"))
    
    data("airway")
    airway$dex <- relevel(airway$dex, ref = "untrt")
    dds <- DESeqDataSet(airway, design = ~ cell)
    dds <- DESeq(dds)
    vst <- assay(vst(dds))
    

    Interactive PCA via PCAtools

    PCAtools is a straight-forward package for principle component analysis.

    shinyPCAtools(vst, metadata = colData(dds), annot.by = c("cell", "dex"), 
                  color.by = "dex", shape.by = "cell", scale = TRUE, height = 850)
    

    Larger (scRNA) Dataset

    shinyPCAtools Works well on larger datasets, though it takes significant time for the PCA to run. Removing a much greater percentage of features is highly recommended.

    shh(library("scRNAseq"))
    shh(library("scran"))
    shh(library("scuttle"))
    shh(library("scater"))
    data <- ZeiselBrainData()
     
    # # Remove genes expressed in few cells.
    data <- data[rowMeans(counts(data) != 0) > 0.05, ]
    data <- computeSumFactors(data, cluster = quickCluster(data))
    data <- logNormCounts(data)
    data$Cell.Type <- factor(data$level1class)
    
    shinyPCAtools(logcounts(data), metadata = colData(data), annot.by = c("Cell.Type", "tissue", "age"), 
                  color.by = "Cell.Type", removeVar = 0.9, scale = TRUE)
    

    Interactive Differential Expression via DESeq2

    This widget was heavily inspired by the interactivate function from the InteractiveComplexHeatmap package. It wraps DESeq2 and will run differential expression analysis if not provided a results dataframe as well.

    Gene labels can be added to the MAplot and volcano plot by clicking a point. The labels can also be dragged around, though adding labels will reset the position, so it’s recommended to add all labels prior to re-positioning them. Gene sets can be highlighted easily if provided.

    Multiple comparisons can also be provided for switching between analyses quickly.

    deseq.res1 <- results(dds, contrast = c("dex", "trt", "untrt"))
    dds <- DESeqDataSet(airway, design = ~ cell)
    dds <- DESeq(dds)
    deseq.res2 <- results(dds, contrast = c("cell", "N080611", "N052611"))
    deseq.res3 <- results(dds, contrast = c("cell", "N61311", "N080611"))
    deseq.res4 <- results(dds, contrast = c("cell", "N080611", "N61311"))
    res <- list("trt v untrt" = as.data.frame(deseq.res1), 
                "N080611vN052611" = as.data.frame(deseq.res2), 
                "N61311vN080611" = as.data.frame(deseq.res3), 
                "N080611vN61311" = as.data.frame(deseq.res4))
    
    shinyDESeq2(dds, res = res, genesets = hs.msig, annot.by = c("cell", "dex"))
    

    Correlating DE Results

    This widget creates scatter plots for arbitrary combinations of DE results. It takes a named list of dataframes as input and will plot scatter plots of log2 Fold Change values for each gene. It accepts up to 4 results dataframes and will generate plots for all combinations of them along with a regression line and correlation testing. Points are colored by significance in each DE analysis. Results dataframes from edgeR, limma, and DESeq2 will automatically have the appropriate columns used for plotting, but users can also provide the column names for their significance value or fold change column as necessary.

    Gene labels can be added to a plot by clicking a point. The labels can also be dragged around, though adding labels to a plot will reset the label positions for said plot, so it’s recommended to add all labels prior to re-positioning them.

    shinyDECorr(res, genesets = hs.msig, height = 800)
    

    Visit original content creator repository
    https://github.com/j-andrews7/iBET

  • AvatarImagePicker

    AvatarImagePicker & AuthSettings

    &

    Version Carthage Compatible License Platform Swift

    Description

    AvatarImagePicker is a photo library and camera Image Picker for iOS
    written in Swift, it’s just a single line of code, support for selecting user’s avatar by Camera or Photo Library, editing the selected image. Also, it supports auth verification, if camera or photo library was denied, it will alert the user to the settings for opening it. it means to replace for UIImagePickerController. Compatible with both Swift and Objective-C.

    Installation

    CocoaPods

    pod 'AvatarImagePicker'

    Carthage

    github "janlionly/AvatarImagePicker"

    Swift Package Manager

    .package(url: "https://github.com/janlionly/AvatarImagePicker.git", .upToNextMajor(from: "1.3.0")),

    Usage

    AvatarImagePicker is presented with an actionsheet for camera and photo library, and then presented an ImagePickerController, optional some properties supports to customize, like sourceTypes, presentStyle and dismissAnimated.

    Remember to add NSCameraUsageDescription and NSPhotoLibraryUsageDescription‘s keys for descriptions to your Info.plist

    Swift

    let picker = AvatarImagePicker.instance
    
    // optional: custom properties
    picker.dismissAnimated = false // default is true
    picker.sourceTypes = [.camera] // default is [.camera, .photoLibrary]
    picker.presentStyle = .overFullScreen // default is .fullScreen
    
    // this method includes authorizing for photolibrary and camera.
    picker.present(allowsEditing: true, selected: { (image) in
    	// selected image
    }) {
    	// tapped cancel
       } 
    
    
    // v1.3.2 updated: support to customize actions for sheet
    picker.sourceTypes = [.camera, .customAction]
    weak var weakSelf = self
    picker.customActions = ["Delete": { weakSelf?.imageView.image = nil }]
    
    
    // or you can call only auth photolibrary and camera, it will alert the user to go to settings if the photolibrary or camera was denied.
    let isAuthSuccess = AuthSettings.authPhotoLibrary(message: "auth photolibrary to get your avatar") {
      print("auth success")
      // go to present image picker controller(photo library), customize your operation here.
    }
    _ = AuthSettings.authCamera(message: "auth camera to get your avatar") {
      print("auth success")
      // go to present image picker controller(camera), customize your operation here.
    }

    Objective-C

    [[AvatarImagePicker avatarImagePicker] presentWithAllowsEditing:YES selected:^(UIImage * _Nonnull image) {
            // selected image
        } cancel:^{
            // tapped cancel
        }];

    Requirements

    • iOS 9.0+
    • Swift 4.2 to 5.2

    Author

    Visit my github: janlionly
    Contact with me by email: janlionly@gmail.com

    Contribute

    I would love you to contribute to AvatarImagePicker

    License

    AvatarImagePicker is available under the MIT license. See the LICENSE file for more info.

    Visit original content creator repository https://github.com/janlionly/AvatarImagePicker
  • AvatarImagePicker

    AvatarImagePicker & AuthSettings

    &

    Version Carthage Compatible License Platform Swift

    Description

    AvatarImagePicker is a photo library and camera Image Picker for iOS
    written in Swift, it’s just a single line of code, support for selecting user’s avatar by Camera or Photo Library, editing the selected image. Also, it supports auth verification, if camera or photo library was denied, it will alert the user to the settings for opening it. it means to replace for UIImagePickerController. Compatible with both Swift and Objective-C.

    Installation

    CocoaPods

    pod 'AvatarImagePicker'

    Carthage

    github "janlionly/AvatarImagePicker"

    Swift Package Manager

    .package(url: "https://github.com/janlionly/AvatarImagePicker.git", .upToNextMajor(from: "1.3.0")),

    Usage

    AvatarImagePicker is presented with an actionsheet for camera and photo library, and then presented an ImagePickerController, optional some properties supports to customize, like sourceTypes, presentStyle and dismissAnimated.

    Remember to add NSCameraUsageDescription and NSPhotoLibraryUsageDescription‘s keys for descriptions to your Info.plist

    Swift

    let picker = AvatarImagePicker.instance
    
    // optional: custom properties
    picker.dismissAnimated = false // default is true
    picker.sourceTypes = [.camera] // default is [.camera, .photoLibrary]
    picker.presentStyle = .overFullScreen // default is .fullScreen
    
    // this method includes authorizing for photolibrary and camera.
    picker.present(allowsEditing: true, selected: { (image) in
    	// selected image
    }) {
    	// tapped cancel
       } 
    
    
    // v1.3.2 updated: support to customize actions for sheet
    picker.sourceTypes = [.camera, .customAction]
    weak var weakSelf = self
    picker.customActions = ["Delete": { weakSelf?.imageView.image = nil }]
    
    
    // or you can call only auth photolibrary and camera, it will alert the user to go to settings if the photolibrary or camera was denied.
    let isAuthSuccess = AuthSettings.authPhotoLibrary(message: "auth photolibrary to get your avatar") {
      print("auth success")
      // go to present image picker controller(photo library), customize your operation here.
    }
    _ = AuthSettings.authCamera(message: "auth camera to get your avatar") {
      print("auth success")
      // go to present image picker controller(camera), customize your operation here.
    }

    Objective-C

    [[AvatarImagePicker avatarImagePicker] presentWithAllowsEditing:YES selected:^(UIImage * _Nonnull image) {
            // selected image
        } cancel:^{
            // tapped cancel
        }];

    Requirements

    • iOS 9.0+
    • Swift 4.2 to 5.2

    Author

    Visit my github: janlionly
    Contact with me by email: janlionly@gmail.com

    Contribute

    I would love you to contribute to AvatarImagePicker

    License

    AvatarImagePicker is available under the MIT license. See the LICENSE file for more info.

    Visit original content creator repository https://github.com/janlionly/AvatarImagePicker
  • React

    What the project does

    This project is a collection of small projects i did as part of the learning curve which was required during my journey learning ReactJs
    Each small project has its own ReadMe file
    It covers the following subjects

    • Components
    • Rendering
    • Styling
    • Internals (including component life cycle)
    • Access the Web
    • Routing
    • Forms and Validation Click for Quick Preview
    • Authentication Click Here for Preview
    • Context
    • HOC
    • Ref
    • Pure redux and react redux
    • Render props
    • Hooks

    Why the project is useful and for whom

    Audience Usefulness
    Beginner React Developer Beginner can find small examples to do and compare his solution with what I did. The user that will do the examples in the order described below will have a very good starting point developing React Apps
    Advanced React Developer Advanced can find

    1. An excellent starting project for every React project which uses authentication – Authentication/authentication_server_firebase Click Here for Preview
    2. Generic & easy to use form component – Forms/form_simple_input_with_validation usefull Click for Quick Preview

    How users can get started with the project

    Audience Project Order
    Beginner React Developer
    1. react_max_assignment_1
    2. react_max_assignment_2
    3. Redux/todolist_no_redux
    4. tic_tac_toe
    5. Router example
    6. Component life cycle examples
    7. Axios examples
    8. Form examples
    9. Authentication examples
    10. Ref examples
    Advanced React Developer Advanced can find

    1. An excellent starting project for every React project which uses authentication – Authentication/authentication_server_firebase
    2. Generic & easy to use form component – Forms/form_simple_input_with_validation usefull
    3. Context examples
    4. HOC examples
    5. Pure redux and react redux examples
    6. Render props example
    7. Hooks example

    Where users can get help with the project

    contact me at natankrasney@gmail.com or via my linkedin account

    Who maintains and contributes to the project

    Nathan Krasney : https://il.linkedin.com/in/nathankrasney

    More info on React

    License

    All projects in this React repository are MIT licensed. Copyright (c) Nathan Krasney 2019.

    Visit original content creator repository
    https://github.com/NathanKr/React

  • pkgbuild-brother-hll3230cdw

    GNU GENERAL PUBLIC LICENSE
    Version 2, June 1991
    Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
    
    Everyone is permitted to copy and distribute verbatim copies
    of this license document, but changing it is not allowed.
    Preamble
    The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
    When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
    To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
    For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
    We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
    Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
    Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
    The precise terms and conditions for copying, distribution and modification follow.
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    
    0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
    
    1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
    
    2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
    
    a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
    
    b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
    
    c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
    
    3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
    
    a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    
    b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    
    c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
    
    4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
    
    5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
    
    6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
    
    7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
    
    8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
    
    9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
    
    10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
    
    NO WARRANTY
    11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
    
    12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    END OF TERMS AND CONDITIONS
    How to Apply These Terms to Your New Programs
    If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
    To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
    one line to give the program's name and an idea of what it does.
    Copyright (C) yyyy  name of author
    
    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    Also add information on how to contact you by electronic and paper mail.
    If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
    type `show w'.  This is free software, and you are welcome
    to redistribute it under certain conditions; type `show c' 
    for details.
    The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
    You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
    Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
    
    signature of Ty Coon, 1 April 1989
    Ty Coon, President of Vice
    This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.
    
    

    Visit original content creator repository
    https://github.com/lkrms-pkgbuilds/pkgbuild-brother-hll3230cdw

  • foodgram

    Foodgram

    Both a recipe website & a shopping list service for you to never forget what
    you need to buy to cook that fancy meal you’ve heard or seen. The project
    can be tweaked to either an English or Russian interface thanks to rosetta
    and it showcases my skills as a Python backend developer able to docker &
    pytest. Please find in the description below the tools and stack used and
    the motivation behind the project.

    Table of contents

    Description

    Ever wanted to become a gourmet or a real meal maker? Try out others’
    recipes to both your and their satisfaction or otherwise? Or build on this
    to come up with a better-looking thingy, featuring more languages than just
    Eng/Rus? Well, this project may be your
    starting point. Sign up/in to post/edit/delete your recipes, add others’ as
    your favourites or subscriptions & generate downloadable pdf shopping lists
    in line with the recipes you’d like to try. The shop items just sum up if
    duplicate, and go alphabetically. The admin zone & the docs (in Russian) follow.

    This project helped me a lot in further grasping the following:

    • Set up a Django app for it to interact with third-party APIs;
    • Use own scripts to populate the database from csv after re-deployments via
      CI-CD;
    • Create a custom API based on a Django project & as per its tech docs/requirements;
    • Connect friendlily a React SPA to a backend app for both to perform as one;
    • Build & deploy both locally & remotely docker images & containers;
    • Enjoy more of DevOps, including CI/CD;
    • Use further both DjDT for the dev & Telegram bot notifications about GitHub Actions deploys – for better performance & automated deployments;
    • Create a downloadable PDF with ingredients & their quantities for your
      favourite recipes to go shopping with.

    Tools & stack: #Python #Django #DRF #Json #Yaml #API #Docker #Nginx
    #PostgreSQL #Gunicorn #Djoser #JWT #Postman #TelegramBot #Flake8 #Ruff
    #Black #Mypy #DjDT #Django-cleanup

    Back to TOC

    Usage

    • Visit & sign up/in with an email-password
      pair, log in
    • Or get straight to the recipes anonymously
    • See the demo video

    Back to TOC

    Installations

    Local non-Docker

    cd into a folder of your choice, clone the project from https://github.com/kirkoov/foodgram.git, cd foodgram & create your virtual env (venv, e.g.
    with poetry). This installation case is best to tweak to your needs and
    language. rosetta comes included, but for further ops should be
    re-installed in place to work properly & entered like
    http://localhost:8000/rosetta/ only while under an admin session. If you care
    about English wording only for your admin zone, uninstall rosetta.

    1. In the same Terminal, cd backend or elsewhere you’ve put the requirements.txt & run poetry add $( cat requirements.txt ). Take the above note about rosetta or just remove its lines from the requirements.txt before running this command.

    2. If you want to try both the frontend and backend locally, in the frontend folder package.json’s “proxy” change the "http://web:8000/" to "http://127.0.0.1:8000/" & do not forget to undo this change later if required. Then in a Terminal, to launch the frontend, run & ignore warnings:

    • npm install;
    • npm run build;
    • npm start.
    3. In the project folder, where the .env.example file is, create your own .env file like below. If you plan to work with an sqlite3 db only, no need to include all the fields:

    DEBUG=True
    ALLOWED_HOSTS="127.0.0.1 0.0.0.0 localhost foodgram.zapto.org"
    SECRET_KEY='django-insecure-tzt1(#hb_0%wb!!12@1$h#-4a36=)d4=(a3cyt%+hgf$x7o$hc'
    POSTGRES_DB=foodgram_postgre
    POSTGRES_USER=foodgram_user
    POSTGRES_PASSWORD=<insert your pwd>
    DB_HOST=db
    DB_PORT=5432
    

    Then run:

    • python manage.py makemigrations (usually unnecessary with an sqlite3);
    • python manage.py migrate;
    • python manage.py createsuperuser;
    • (optional) python manage.py test or poetry run pytest from the backend
      folder containing the pytest.ini;
    • python manage.py runserver.

    NB: to handle img consistency, django-cleanup is used. By default, the admin zone accepts
    images<=1Mb, although when running live locally, the frontend may accept
    larger images. Still, in a live server case, the nginx container will
    instruct its Docker cousins not to.

    4. Skip if para. 2 above doesn’t apply. Back in the browser, reload the page http://localhost:3000 for the test recipes to appear.

    6. The admin/frontend language can be swapped for Russian before the runserver command. See the local Docker deploy instructions below for details.

    7. For language translation control, if applies, visit http://localhost:8000/rosetta/.

    8. Run python manage.py runserver and refresh the http://localhost:3000 if necessary.

    9. Navigate, do/undo favourites/subscriptions, try the pdf shopping list download and/or build on this repo.

    Back to TOC

    Local Docker

    Ubuntu 22, Docker 25.0.4, docker compose v2.24.7

    1. Make sure your system’s port 80 is not busy (by default the project uses this port, which can be changed though) and run in a Terminal:

    • make the initial clone steps as above;
    • cd foodgram && nano .env like in the previous installation instructions.

    NB: the settings.py has it in such a way that Docker containers need
    its DEBUG var in the .env as False. The opposite is used for dev (DjDT, db.
    sqlite3), while with False the project defaults to PostgreSQL.

    2. Decide what ports will be piped locally for the containers to run (by default 80:80). Different ports should be indicated in the infra/docker-compose.yaml, e.g. in the nginx service:

    image: nginx:1.19.3
     ports:
     # Live server
     # - "8000:80"
     # Loc dev
     - "80:80"
    
    3. Define the admin zone language (the default Eng vs Rus):

    • change the LANGUAGE_CODE accordingly (settings.py);
    • unzip/replace the frontend public & src folders (see the zip files);
    • if you want the ingredients in Eng too, see more details below, just bear
      in mind that all of them can be changed in the backend root folder’s
      csv-files (with their bak cousins saved in the data folder).
    4. In the frontend folder’s package.json, make sure the “proxy” field at the file bottom has the value of "http://web:8000/".

    5. Back in the Terminal, cd to the infra folder containing the docker-compose.yaml, run & wait for the commands to finish & start the containers:

    sudo docker compose up
    which may eventually include (->):

    ✔ Network infra_default Created 0.1s
    ✔ Volume "infra_media" Created 0.1s
    ✔ Volume "infra_static_frontend" Created 0.0s
    ✔ Volume "infra_pg_data" Created 0.0s
    ✔ Volume "infra_static" Created 0.0s
    ✔ Container infra-db-1 Created 0.4s
    ✔ Container infra-frontend-1 Created 0.3s
    ✔ Container infra-backend-1 Created 0.3s
    ✔ Container infra-nginx-1 Created
    
    6. Continue in another Terminal window, from the same infra folder:

    • sudo docker compose exec backend python manage.py migrate;
    • sudo docker compose exec backend python manage.py collectstatic.

    -> 169 static files copied to '/app/static_django'

    7. If you want none of the test admin, users, recipes, ingredients, subscriptions, & would rather do them on your own, run:

    • sudo docker compose python manage.py createsuperuser;
    • populate them tables from the admin zone, do your ingredients (name,
      measurement unit), etc;
    • still, to get the look and feel locally, you may want to use the defaults
      in Rus, just load this fixture: sudo docker compose exec backend python manage.py loaddata db.json;

    -> Installed 2240 object(s) from 1 fixture(s)

    • or/and you may also want to use the default ingredients: sudo docker compose exec backend python manage.py import_csv eng + sudo docker compose exec backend python manage.py import_csv rus;
    • then check in the admin zone if these imported ingredients (translated)
      are in the DB.

    NB: if for some reason this is not the first time you run these
    commands & the Docker volumes have not been rmed, all such data will
    remain as is & you may see messages about duplicate values in the DB or/and
    that no migrations are necessary.

    NB: if you plan to work with both Rus/Eng translations, make sure the
    settings.py lang_code has the value you need, and the
    makemessages/compilemessages do work in the backend container. Open
    another Terminal and from the same infra folder run:
    sudo docker compose exec backend bash;
    apt update && apt upgrade -y && apt install gettext-base && apt install gettext. Then quit (Ctrl+d) and run:

    sudo docker compose exec -it backend django-admin makemessages --all --ignore=env;
    sudo docker compose exec -it backend django-admin compilemessages --ignore=env.

    And for the language changes to take effect, Ctrl+c in the other
    Terminal to stop the containers and sudo docker compose up --build
    again. Refresh the admin zone page. Should there occur any untranslated
    fields, stop & down the containers, check the lang_code in the settings.py,
    do the sudo docker system prune -af & repeat from para. 3 hereof.

    8. If for some reason you need a cache purge, run sudo docker compose exec backend python manage.py clear_cache.

    9. If you never changed the ports & docker-compose file, the ready-made recipes, admin zone & docs should be live & kicking at:

    10. To delete it all, do the Ctrl+c + sudo docker compose down -v + sudo docker system prune -af + rm -r the project folder too.

    Back to TOC

    Remote Docker, GitHub repo-based

    Ubuntu 22, Docker 25.0.4 & docker compose v2.24.7

    1. Make sure your system’s port 80 is not busy (see the prev installation intro) & ssh to your live server. If needed, check that port 8090 there is free (ss -ltn), since it’s the project’s backend default.

    2. Git-clone & .env the project as before (see above).

    3. cd infra & in the docker-compose.yaml change the ports for a live server run like so:

     nginx:
     image: nginx:1.22.1
     ports:
     # Live server
     - "8090:80"
     # Local Docker dev
     # - "80:80"
     volumes:
     ...
    
    4. Follow the 3-8 steps of the Local Docker install.

    5. If you never changed the ports & docker-compose file, the project recipes, admin page & docs should be live at:

    • http(s)://your_domain_or_IP_address/;
    • http(s)://your_domain_or_IP_address/admin/;
    • http(s)://your_domain_or_IP_address/api/docs/.

    Back to TOC

    Local containers, Docker image-based

    Ubuntu 22, Docker 25.0.4 & docker compose v2.24.7

    1. Git-clone the repo (see above), tweak the backend/front end folders if needed, build your images locally or use mine, then cd to the infra folder & run:

    sudo docker compose -f docker-compose.production.yaml up (please check the names of the containers & ports)

    2. In another Terminal, do the same as in the previous install instructions, but skip the git-cloning; and remember that the sudo docker compose commands must be used with the -f docker-compose.production.yaml rather. And remember the case when you need your frontend in the other language (this requires a separate image pre-build on your own after unzipping the frontend archive).

    3. To stop & remove container, run sudo docker compose down -v + the ones specified in the prev instructions (e.g. the Local Docker‘s step 10).

    4. The ready recipes, admin & docs pages should be at:

    Back to TOC

    Remote containers, Docker image-based

    This project been tested on a live server with Ubuntu 22, Docker 25.0.4 &
    docker compose v2.24.7.

    1. Ssh to your server & run:

    npm cache clean --force
    sudo apt clean
    sudo journalctl --vacuum-time=1d
    
    2. Then do:

    sudo apt update
    sudo apt install curl
    curl -fSL https://get.docker.com -o get-docker.sh
    sudo sh ./get-docker.sh
    sudo apt install docker-compose-plugin
    
    3. mkdir foodgram && cd foodgram & from your local Terminal where the project been git-cloned and from its infra folder, check the conf of the docker-compose.production.yaml:

    nginx:
     image: nginx:1.22.1
     ports:
     # Live server
     - "8090:80"
     # Local Docker dev
     # - "80:80"
    

    save, close & run
    scp docker-compose.production.yaml <yourServerUser>@<yourServerIP>:foodgram

    4. Create remotely or scp from local Terminal to the same remote folder your .env file (see above) + scp nginx.conf <yourServerUser>@<yourServerIP>:foodgram

    5. Then from the remote ssh-Terminal run docker compose -f docker-compose.production.yaml up -d

    6. If ok, take the same steps as from the prev instructions’ para 2. Otherwise, stop & run without the -d flag to see the output.

    7. The project, admin page & docs availability:

    • http(s)://your_domain_or_IP_address/ (if you never changed the ports &
      docker-compose file);
    • http(s)://your_domain_or_IP_address/admin/;
    • http(s)://your_domain_or_IP_address/api/docs/.

    Back to TOC

    Credits

    • The frontend (React) is a fork from YandexPracticum’s repo.

    Back to TOC

    Licence

    MIT

    Back to TOC

    How to contribute

    Do contact in case you think there’s a chance to. We’d both be better off
    reading the Contributor Covenant which is a standard to start with.

    Back to TOC

    Authors

    kirkoov (Django backend), YandexPracticum (React frontend)

    Visit original content creator repository
    https://github.com/kirkoov/foodgram