teleren/devto huggingface dataset:
transparent-titlebar: transparent title bar with native title label in Electron for Mac
Tags: electron, macos, showdev
Published: 2018-01-02 08:38:56

---
title: "transparent-titlebar: transparent title bar with native title label in Electron for Mac"
published: true
description: 
tags: electron,macos,showdev
---

![Example](https://thepracticaldev.s3.amazonaws.com/i/i6j7s8zedltdvfnmhnht.gif "Example")

GitHub: https://github.com/seanchas116/transparent-titlebar

## Customizing title bar of Electron apps in Mac

Many cool Mac apps customizes title bar and often hides original title bar background. Electron provides [titleBarStyle option](https://electronjs.org/docs/api/frameless-window#hidden) to hide original titlebar, but it also hides the title label.
If you want to make the title bar transparent while leaving the native title label visible, you'll need another way.

### why needs native title label?

The best benefit of the native title level is [Represented File](https://electronjs.org/docs/tutorial/desktop-environment-integration#represented-file-of-window-macos).
It's difficult to reimplement this in DOM perfectly.

## transparent-titlebar

I developed [transparent-titlebar](https://www.npmjs.com/package/transparent-titlebar) library, which uses Cocoa APIs to set title bars transparent while leaving title labels visible.
It customizes `NSWindow`'s `titlebarAppearsTransparent` and `styleMask` to show content with entire space of window.

This is how to use this library:

```js
let win: BrowserWindow
const transparentTitlebar = require('transparent-titlebar')

// Setup window to use transparent titlebar
transparentTitlebar.setup(win.getNativeWindowHandle())

// Set title color to red (must be called whenever the title has changed)
transparentTitlebar.setColor(win.getNativeWindowHandle(), 1, 0, 0, 1)
```

You may need to run [electron-rebuild](https://github.com/electron/electron-rebuild) after install.

## change color (in hacky way)

It's hard to change the text color of the title because Cocoa does not provide any API to change it directly.
Fortunately I found a way to find NSTextField from title bar subviews and change its color: http://stackoverflow.com/a/29336473

`setTitleBarColor` function uses this solution. It must be called whenever after the title has changed.
It is a hack and probably you have to use it with caution.
(this is because I published this in a separate package instead of a pull request to Electron)
Should I go with Python, Java or Ruby in 2018?
Tags: discuss, beginners
Published: 2018-01-02 07:49:39

---
title: Should I go with Python, Java or Ruby in 2018?
published: true
tags: discuss, beginner
---

I wanted to ask you all a question, as my first post on dev.to (If I may?).

I'm a 25 year old Autistic newbie to the Programming forte, and love python, Linux and web development (HTML, CSS, etc).

What would you personally, and professionally recommend be the "Go To" Language to spend a lot of time working on this year? 1) Python, 2) Ruby or 3) Java?
Progressive Web Apps (Part 2)
Published: 2020-04-08 06:08:19

---
title: Progressive Web Apps (Part 2)
published: true
date: 2018-01-02 00:00:00 UTC
tags: 
canonical_url: https://medium.com/@pa1nd/progressive-web-apps-part-2-eb46f7bf5363
---

This is the second post explaining PWAs. [The first part of it is here.](https://blog.penguin.academy/progressive-web-apps--part-1-/)

## Technology

To understand, how amazing PWAs are, and to have a look in the future of their development, we have to understand where the technology comes from and why we did not have it before.

The fundament of PWAs is a technology called “appmanifest”. It is developed by “The World Wide Web Consortium” (W3C) — the main international standards organisation for the World Wide Web. [The last version of the technical standard draft](https://www.w3.org/TR/appmanifest/) is a few days old, which illustrates its active current development.

The speed at which new features become available is determined by two entities: the W3C (as seen above) and the browser-developing companies (Mozilla: Firefox, Google: Chrome, Apple: Safari and iOS, Netscape: just joking…).

Google has been pushing forward with PWAs, while Apple was initially very skeptical about them. At the moment, the support for PWAs is already pretty good on Android and Chrome, as well as on Firefox. [The great news: Apple also started implementing](https://dockyard.com/blog/2017/10/25/work-on-web-app-manifest-in-webkit-has-begun) the standard so it is only a matter of time till the features start working on iOS. Thus, every major browser now supports or is to support PWAs. The graph below shows the support for push notifications as of September 2017.

![](https://blog.penguin.academy/content/images/2020/04/1_4WuFRBz0WzzcWXKXaoKWcQ.jpeg)<figcaption>Support for web push notifications as of September 2017</figcaption>

## Support for important features

Two important features that every client would like to use are:

1. **Installing the web app on the home screen.** This works on all major devices today already. After installing the web app, it will open in fullscreen (without the URL bar) and directly offer an app-like feeling.
2. **Sending push notifications.** This is possible an all major devices (including desktops) but is missing on iOS so far. We have no information so far when it will be released on iOS.

## What features will be available

Progressive Web Apps include a bundle of amazing features. Here you have an overview over the features that are already available under Chrome.

![](https://blog.penguin.academy/content/images/2020/04/1_5QoyUL5hLoAeERlADP9rwg.jpeg)<figcaption>Support for Progressive Web Apps across platforms in Chrome</figcaption>

* * *

At Penguin we are excited to see that the interest in PWAs is growing very fast in Switzerland. If you want to figure out more about this awesome technology, do not hesitate to contact us!
Would be great to get your honest feedback on Curriculum - http://curriculum.co.ke/
Tags: education, kenya
Published: 2018-01-01 21:05:13

---
title: "Would be great to get your honest feedback on Curriculum - http://curriculum.co.ke/"
published: true
description: "[Curriculum](http://curriculum.co.ke/) is an online/virtual Library. Here, you can find past-papers, Revision papers, professional papers, books and syllabuses of various examination bodies like KASNEB, KNEC etc.

The current focus is Kenya"
tags: ["education", "kenya"]
---
A year to divide and conquer - 2018
Published: 2018-01-01 20:09:17

---
title: A year to divide and conquer - 2018
published: true
description: 
tags: 
---

From my end let me use this opportunity to wish everybody a happy new year.   Lol my timezone though, that's  by the way. 

The year 2017 happens to be a great year for me, a lot of goals though unable to fulfill few but to some extent, let me call it a successful year. 

Maybe you are in my shoes too,  you planned a lot and set goals but due to some reasons you are unable to fulfill it. The year 2018 is here,  forget about your past disappointments and focus on the future. Remember the future has a lot to offer than your past, so be focused and determined. 

Remember to set your goals, divide it into various sections and implement one after the other,  trust me in few months time you'll achieve a lot. 

One love from here.
Today I am shutting down my side project
Tags: discuss
Published: 2018-01-01 17:19:39

---
title: Today I am shutting down my side project
published: true
tags: discuss
---

Hi,

Today I am shutting down my project about donations which focused on helping open source projects and authors of free content accept recurring payments. 

{% twitter 947875134345547777 %}

![https://pbs.twimg.com/media/DSeGUSTXUAEU-VE.jpg:medium](https://pbs.twimg.com/media/DSeGUSTXUAEU-VE.jpg:medium)

I would like to use this opportunity to open a discussion about open source funding. What I have learned over this time is that donations rarely work sustainable for open source projects. Users should really-really like the project to support it. And this is quite a hard job to keep people engaged over time. SupporterHQ was not particularly successful at this. Several competitors do a better job. We collected a list of competitor services in an awesome list https://github.com/60devs/awesome-crowdfunding-services.

How do you feel about donating money to open source projects in 2018? Do you regularly donate, occasionally or never?
SanDisk’s Connect Drive app and screen overlay error on Android Marshmallow
Tags: android, apps, flashdrive
Published: 2020-07-25 21:20:22

---
title: SanDisk’s Connect Drive app and screen overlay error on Android Marshmallow
published: true
date: 2018-01-01 17:10:27 UTC
tags: android,apps,flashdrive
canonical_url: 
---

Yesterday I installed and attempted to run the SanDisk’s Connect Drive app so I could access my wireless flash drive from my Android smartphone. However, the app refused to run, trowing an notification explaining that the ‘[screen overlay settings](https://www.howtogeek.com/271519/how-to-fix-the-screen-overlay-detected-error-on-android/)‘ must be turned off, or else access permissions could not be set. This problem persisted until, after launching the ‘[recent application menu](https://www.tomsguide.com/us/close-android-apps,news-21281.html)‘ (with the square button), I noticed a ‘ES file Explorer’ window appeared, signaling that this app was running. However, I did not open this app. I realized then, that maybe this app caused the problem by actively drawing over other apps. As soon as I uninstalled ES file explorer, Connect Drive let me set permissions and my wireless flash drive worked flawlessly.
How to make reusable CompositeDisposable and Kotlin extension
Tags: android, rxjava, kotlin
Published: 2018-01-01 11:22:21

---
title: How to make reusable CompositeDisposable and Kotlin extension
published: true
description: Make reusable CompositeDisposable and Kotlin extension
tags: Android,RxJava,Kotlin
---

## Prepare

### app/build.gradle

```groovy
ext {
  rxjava2_version = "2.1.7"
}
dependencies {
  implementation "io.reactivex.rxjava2:rxjava:${rxjava2_version}"
}
```
### Make "AndroidDisposable"

#### Edit

**The same effect can be obtained by using "CompositeDisposable#clear"**

`CompositeDisposable` is can not reuse when already disposed. If you want sync disposable lifecycle with Android Activity lifecycle, it is possible to correspond by making simple wrapper.

```kotlin
class AndroidDisposable {
    private var compositeDisposable: CompositeDisposable? = null

    fun add(disposable: Disposable) {
        if (compositeDisposable == null) {
            compositeDisposable = CompositeDisposable()
        }
        compositeDisposable?.add(disposable)
    }

    fun dispose() {
        compositeDisposable?.dispose()
        compositeDisposable = null
    }
}
```

#### How to use

```kotlin
class MainActivity : AppCompatActivity() {
    private disposable = AndroidDisposable()

    override fun onStart() {
        super.onStart()
        disposable.add(/* Some disposable */)
    }

    override fun onStop() {
        disposable.dispose()
        super.onStop()
    }
}
```

## Kotlin Extension

Kotlin can add new function / method for existing class (An entity is a static method that takes an instance of the target class as the first argument). I will extend `Disposable` and make it easy to use `AndroidDisposable`.

```kotlin
operator fun AndroidDisposable.plusAssign(disposable: Disposable) {
    add(disposable)
}

fun Disposable.addTo(androidDisposable: AndroidDisposable): Disposable
    = apply { androidDisposable.add(this) }
```

#### How to use

```kotlin
val texts = listOf("1", "2", "3")

// Operator
disposable += Observable.fromIterable(texts)
    .map { it.toInt(10) }
    .reduce { t1, t2 -> t1 + t2 }
    .subscribe()

// or
Observable.fromIterable(texts)
    .map { it.toInt(10) }
    .reduce { t1, t2 -> t1 + t2 }
    .subscribe()
    .addTo(disposable)
```
Future proof your footer's copyright date with the current year
Tags: copyright, newyear, javascript, webdev
Published: 2018-01-01 03:17:17

---
title: Future proof your footer's copyright date with the current year
published: true
description: If you're a dev, one of the tasks you may perform manually every year is updating a site's copyright date. Well worry no more, use these tips to let it update automatically.
tags: copyright, new year, javascript, webdev
---

It's a new year and one of the quickest ways for your site to seem dated is by not updating the copyright year in the footer.

To combat this, the easiest way is to have your site generate the current year for you.

Here are a few code snippets in a few select languages.

#### JavaScript

```javascript
<script type="text/javascript">
  document.write(new Date().getFullYear());
</script>
```

#### Ruby

```ruby
<%= Time.now.year %>
```

#### PHP

```php
<?php echo date("Y"); ?>
```

#### Ember.js

```javascript
// You'd most likely want to create a component to handle this. In the component's JS file, create a property like `currentYear`
...
currentYear: new Date().getFullYear(),
...
```

```
// Then in your component's handlebars file, reference the property like this.
<footer>&copy; 2014 - {{currentYear}}</footer>
```

#### Jekyll

Future proofing a Jekyll project's copyright is a little more manual, but [here are step by step instructions on future-proofing your Jekyll copyright date](https://michaelsoolee.com/jekyll-copyright/).

***

If you have any other examples, feel free to leave it in a comment and I'll update this post.

***

Originally posted on [Michael Lee](https://michaelsoolee.com/future-proof-copyright-date/)
Adding View models to a Laravel project
Tags: viewmodels, laravel, net
Published: 2018-10-13 21:18:08

---
title: Adding View models to a Laravel project
published: true
tags: view models, laravel, .net 
description: Trying to use this design pattern I've discovered in .NET a few years ago.
canonical_url: https://davidllop.com/adding-view-models-to-a-laravel-project
---

Since the beggining of 2017 I started to experiment with different kind of codes   and patterns I didn't used before.

One of that changes came in November when I was developing the [code of this other blog](https://github.com/lloople/blog). I saw that I was duplicating a lot of code inside my controllers on the methods for `create` and `edit` a resource, in which I use the same blade file.

Some data of that view depends on the model I'm editing or creating. For example, if it's an existing record the title should be `Edit post: {$post->title}` instead of `Create a post`. That logic applies to the form action and form method too.

I created a main `FormViewModel`, and every view model dedicated to a form extends it.

```php
abstract class FormViewModel
{

    public $model;
    public $title;
    public $action;
    public $method;

    public function __construct(Model $model)
    {
        $this->model = $model;

        $this->setTitle();

        $this->setAction();

        $this->setMethod();
    }
}
```

This view models are forced to declare the methods called on the constructor

```php
protected abstract function setTitle();

protected abstract function setAction();

protected abstract function setMethod();
```

This is an implementation of the `setTitle` method in the `CategoryDetailViewModel`:

```php
protected function setTitle()
{
    $this->title = $this->model->exists
        ? "Edit Category: {$this->model->name}"
        : "Create Category";
}
```

They can also add more logic in their own constructor, like the `PostDetailViewModel`:

```php
public function __construct(Post $post)
{
    parent::__construct($post);

    $this->published_at = $this->model->exists
        ? $this->model->published_at->format('Y-m-d\TH:i')
        : Carbon::now()->format('Y-m-d\TH:i');

    $this->categories = Category::select('id', 'name')->get();
}

```

Using the view models is very easy, the controller only needs to pass this object to the view

```php
public function edit(Theme $theme)
{
    return view('backend.themes.edit', [
        'view' => new ThemeDetailViewModel($theme)
    ]);
}
```

and the view use the object properties and methods

```php
@section('content')
    <h1>{{ $view->title }}</h1>
    
    <form method="POST" action="{{ $view->action }}">
        {{ method_field($view->method) }}
        {{ csrf_field() }}
        ...
    </form>
@endsection
```
What's your deal?
Tags: discuss
Published: 2017-12-31 20:41:17

---
title: "What's your deal?"
published: true
description: 
tags: #discuss
---
Hi everybody, 

I'm trying to maximise the value of my posts to the dev.to community but I don't know that much about you guys and gals.  

Tell me your deal by answering the following 4 questions in the comments (it shouldn't take more than a minute):

1. How many people work as software developers at your company including you? 
2. How many people work for your company in total (< 10, 10 - 50, 50 - 100, > 100)?
3. How many years have you worked as a professional software developer? 
4. (optional) Is there anything you'd like me to write about that could help you advance your career or increase your effectiveness? What problems or roadblocks are standing in your way? What are your biggest challenges? 

If you're not a professional software developer, I'd love to hear from you too. Are you a student? Or a professional in another field who does a little programming as part of your job? Or a hobbyist? Designer? Manager? Write a quick sentence with your answer in the comments.

I'll tally your responses and share a summary with everyone in a week. Thanks!


Regards, 

Blaine
What's your promise for 2018?
Tags: discuss, happynewyear, promises
Published: 2017-12-31 15:58:04

---
title: What's your promise for 2018?
published: true
tags: discuss #happyNewYear #promises
---

My Promise for 2018
+-----+

Year2018.hardwork.then((success) => {
console.log('work harder');
}, (failure) => {
console.log('Never give up');
});

#HappyNewYear2018 #javascript #JS #es6 #promises
The super programmer
Tags: comic, media, fun, representation
Published: 2017-12-31 12:00:45

---
title: The super programmer
published: true
description: computer science, programming and hacking representation in comics.
tags: comic, media, fun, representation
---

I'm a big fan of comic books, and I enjoy reading many kind of them. Since I started reading comics, I've felt specially hyped when I saw computer science representation in them. So today I decided to make a compilation of the programmers, hackers, and developers in comics. Feel free to add more in the comments!


## The unbeatable squirrel Girl (Doreen)

One of the most powerful heroes in Marvel, kind, funny and crazy with a big fluffy tail... oh and she is a **computer science top student**. In the comic, she's always accompanied by Nancy, her classmate, and there are tons of computer science references. I'm really in love with this character.

![](https://pbs.twimg.com/media/DSPPv1cXUAEfCB-.jpg)

## Doctor Doom

In one of the chapters with Unbeatable Squirrel Girl, Doctor Doom shows a programming language based in assembly he created. But it's only based in the world "DOOM". He doesn't know about C++ tho!

![](https://i.kinja-img.com/gawker-media/image/upload/s--U3h5lKxZ--/c_scale,f_auto,fl_progressive,q_80,w_800/lxxydnouvrttxgxdvdpb.png)

## Batgirl (Barbara Gordon)

She's an amazing heroine, but she's also a super intelligent **hacker**. [**SPOILER**]When she's shot in the back by the Joker, she still beats it helping a group of teen hackers in **Hackerfiles**.   

![](https://scifielements.files.wordpress.com/2015/02/oracle_0005.jpg) 

## Sue Denim, Phreaky Phreddy and Master Blaster

A group of teenager hackers who help save the world from a nuclear catastrophe in **Hackerfiles**. 

![](http://www.writeups.org/wp-content/uploads/Hacker-Speed-Metal-Kids-DC-Comics-h.jpg)

## Jack Marshall

A hacker / programmer, the main character of Hackerfiles who asks for help to the teens mentioned, as he "is the best, but he's already too old for the job". 

![](http://www.writeups.org/wp-content/uploads/Hacker-DC-Comics-Jack-Marshall-a.jpg)

## Iron Man (Tony Stark)

Well, he knows about everything, okay? but he's an electronics geek, programmer, dev, and hacker. Apart from rich, playboy and superhero. 

![](http://www.comicsbeat.com/wp-content/uploads/2013/05/iron-man-3-tony-stark-robert-downey-jr.jpg)

## Black Widow (Nat Romanova) 

Apart from an excellent spy, she's a casual hacker.

![](https://jamjani.files.wordpress.com/2015/07/gg.gif)
Proxy Server Rotation Script in Python
Tags: python, proxyserver
Published: 2017-12-30 15:54:07

---
title: Proxy Server Rotation Script in Python
published: true
description: A proxy server rotation script that works with ProxyMesh
tags: Python, Proxy Server
---
![Proxy Server Rotation Script in Python](https://thepracticaldev.s3.amazonaws.com/i/18eaxrnq802o0xin8uew.jpg)

# Rotating Proxy Servers in Python

Recently, I have used ProxyMesh proxy server for a project. ProxyMesh offers 15 proxy servers, each denoting a specific location (such as us-dc) with 10 IP addresses rotating twice per day.

However, the free trial allows you to have one proxy server at a time. This means that if you are working with a server or CDN that strictly throttles IPs, you have to change the proxy server manually to keep rotating between the 15 proxy servers.

Fortunately, ProxyMesh provides an API that can be used to add and delete the proxy servers in user dashboard. Once a proxy server is assigned to the user, it can be fetched and used. All we need is a script that rotates between the proxy servers, deleting and adding them as required.

Based on this, I have written a script that would rotate through ProxyMesh proxy servers using their API.

## Prerequisites

An account with ProxyMesh, either free trial or paid. Set the user name and password in rotatingproxy.py

```
self.user = ""
self.password = "" 
```

## Usage

### Setting the Proxy Server

```
from rotatingproxy import RotatingProxy

rproxy = RotatingProxy()
```

The proxy server can either be set randomly or selected from an available list of proxy servers. 
The active proxy server is saved in a text file which can be accessed as required.

```
rproxy.set_proxy(israndom="r")  # select a random proxy server

rproxy.set_proxy(proxy_num=1)   # select proxy server with index=1 from the list of proxy servers.
```

### Accessing the Proxy Server

```
def get_proxy_from_file():
    # fetches proxy from proxy.txt
    with open("proxy.txt", "r") as f:
        return loads(f.read())
        
proxy = get_proxy_from_file()        
```

The proxy can now be used with requests:

```
import requests
response = requests.get("url-to-fetch", proxies=proxy)
```

Blog post: http://www.kashifaziz.me/proxy-server-rotation-python.html/

GitHub: https://github.com/kashaziz/rotating-proxy-python
About Windows for devs
Tags: discuss
Published: 2017-12-31 11:58:43

---
title: About Windows for devs
published: true
description: An open question to all devs about Windows
tags: #discuss
---

I've read days ago a #discuss about why people prefer to use Mac (or Linux in my case) for developing instead of Windows, starting a kind of evergreen "OS war", however, my question is: _is it so bad to use Windows in dev?_ independently from what kind of dev you are (web, mobile, desktop etc.)

PS This in __NOT__ meant to start another OS war, please don't, my question is only about real and justified reasons why Windows is not so recommended for dev, even because I'm not a Win user.