teleren/devto huggingface dataset:
ALL environment variables available in the Docker Hub build environment
Tags: dockerhub, docker
Published: 2020-12-28 10:05:21

---
title: ALL environment variables available in the Docker Hub build environment
published: true
description: A few environment variables that might be useful, and were somehow dropped in the documentation
tags: dockerhub, docker
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/3dadyaq9e0fwc1lzoajs.jpg
---
The [Docker Hub documentation](https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing) lists all these environment variables, which are available in your scripts in that environment:

```
    SOURCE_BRANCH: the name of the branch or the tag that is currently being tested.
    SOURCE_COMMIT: the SHA1 hash of the commit being tested.
    COMMIT_MSG: the message from the commit being tested and built.
    DOCKER_REPO: the name of the Docker repository being built.
    DOCKERFILE_PATH: the dockerfile currently being built.
    DOCKER_TAG: the Docker repository tag being built.
    IMAGE_NAME: the name and tag of the Docker repository being built. (This variable is a combination of DOCKER_REPO:DOCKER_TAG.)
```

However, there are quite a few more, which might be useful in a certain environment; these were discovered by just printing the environment variables via a Perl script (which, BTW, [you can use in Docker Hub](https://dev.to/jj/writing-docker-hub-hooks-in-perl-44h2) for your own purposes).

* `SOURCE_TYPE`: this one seems to contain `git`. It might be different if it's pushed directly, or via the API.
* `PATH`: is the regular system PATH. It contains `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`.
* `MAX_LOG_SIZE`: it contains 67108864. Not clear if it can be changed.
* `BUILD_CODE`: no idea what this is. It contains a code.
* `PUSH`: it contains `true` if it's been created via PUSH. Probably other values if it's been automatically launched.
* `GIT_TAG` and `GIT_SHA1`: no idea what the first one is, the second is the commit SHA1.
* `HOSTNAME`: the host it's using to build.
* `DOCKER_HOST`: the socket the client is using to connect, same as in the local docker installation.
* There's something called `SIGNED_URLS`, which holds Amazon urls. No idea what this is, or how it can be useful.
* `DOCKER_TAG` and `CACHE_TAG`, the tag that's being built, like `latest`.
* `PYTHONUNBUFFERED` is equal to 1.
* `SOURCE_REPOSITORY_URL` the repository it's being built from.
* `LOG_BUILD_STEPS` is set to `FALSE`
* `DOCKER_CFG` contains information on the user, including user tokens.

Out of all these, you can probably use `PUSH` or even `GIT_SHA1` to introspect what's being built, and maybe take some actions. For instance, along with [information on the last build](https://github.com/docker/hub-feedback/issues/2062) you could create a script that built only those Dockerfiles that have changed.
Wrap const char* in the Nim language
Tags: nim, ffi, c
Published: 2020-12-28 09:21:35

[Nim language](https://github.com/nim-lang/Nim) has a great FFI with C/C++ which makes it easy to use C/C++ libraries. This article introduces
how to wrap `const char*` in C/C++ backend.

In the Nim world, we often play with `string` which handles the dirty works for us such as resizing the buffer, creating/deleting the memory which can satisfy the most of our needs. However, if we want to interact with other languages, we need the power of `cstring`. Note that `cstring` doesn't mean "string in C", it means compatible string(`char *` in C/C++ backend, JS string in JavaScript backend and so on).

Nim doesn't provide `const char *` for us. But it is easy to make our own one.

You need to import `const char*` types from C/C++ backend using `importc` pragmas. Then make a distinct type for it.

```nim
type
  cstringConstImpl {.importc:"const char*".} = cstring
  constChar* = distinct cstringConstImpl
```

Now, let's look at a simple example using it.

First `emit` the c function, then write the function declaration(`nodecl` pragmas means that we
do not generate the function declaration in the output codes). Finally we construct a `constChar` object and
pass it to the `fn` proc.

```nim
{.emit: """
int fn(const char* a, char b) {
  return 1;
}
"""
.}

proc fn(a: constChar, b: char): int {.importc: "fn", nodecl.}

var x = constChar("abc")
doAssert fn(x, 'c') == 1
doAssert not compiles(fn("abc", 'b'))
doAssert not compiles(fn("abc".cstring, 'b'))
```

We could see that the `fn` proc doesn't accept `string` and `cstring` types and only the `constChar` type is allowed. After looking at the generated C codes using `nim c -r --nimcache:nimcache app.nim` or `nim cpp -r --nimcache:nimcache app.nim`, it does generate `const char* x = "abc";`.


Lastly let's look at an example with C++ backend, it has the same story as above.

Now we need to create a new `.h` file and overload the `fn` functions.

fun.h
```cpp
int fn(const char* a, char b) {
  return 1;
}

int fn(char* a, char b) {
  return 2;
}
```

fun.nim
```nim
proc fn(a: constChar, b: char): int {.importcpp: "$1(@)", header: "fun.h".} = discard
proc fn(a: cstring, b: char): int {.importcpp: "$1(@)", header: "fun.h".} = discard


var a = constChar("abs")
doAssert fn(a, 'b') == 1
var b = cstring("abc")
doAssert fn(b, 'b') == 2
```

Run the codes above using `nim cpp -r fun.nim` and it works!

Reference:
https://github.com/nim-lang/Nim/issues/3720

Nim is a great language. Let's port and wrap more libraries for it.

https://github.com/nim-lang/needed-libraries/issues

https://github.com/nothings/single_file_libs
Add Intellisense for third-party JavaScript libraries in VS Code (it is not always automatic)
Tags: vscode, webdev, beginners, tutorial
Published: 2020-12-28 09:44:28

In VS Code, you may have noticed that if you are using a third-party JavaScript library in your front-end code, you don't get any IntelliSense goodness. 🙁

This is for the case where you using a `script` tag to include a third-party library.

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    ...
  </head>
  <body>
		...
    <script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
    <script src="main.js"></script>
  </body>
</html>
```

In this example, I'm including the [Greensock (GSAP)](https://greensock.com/) animation library. In *main.js*, I don't get IntelliSense for GSAP.

IntelliSense for JavaScript libraries and frameworks is powered by TypeScript type declaration files (files with the *.d.ts* extension) . Type declaration files are written in TypeScript so that they can express the data types of parameters and functions, allowing VS Code to provide a rich IntelliSense experience.

VS Code has [automatic type aquisition](https://code.visualstudio.com/docs/nodejs/working-with-javascript#_typings-and-automatic-type-acquisition), which means that it will automatically fetch these types for you, but with a big caveat.

> Type declaration files are automatically downloaded and managed by Visual Studio Code for packages listed in your project's package.json or that you import into a JavaScript file.

In my use case, I do neither. This is a fairly common scenario in front-end codebases.

Gimme, gimme. Im getting IntelliSense withdrawal! 😖

The simplest solution is to find the NPM package with the types, and include it as a dev dependency. This way, your code can remain the same.

```bash
npm install --save-dev @types/gsap
```

Types for some libraries are sourced from the [DefinitelyTyped GitHub repo](https://github.com/DefinitelyTyped/DefinitelyTyped). Many popular packages follow this `@types/<<library name>>` naming convention also. You can search for NPM packages that have type definitions using [https://www.typescriptlang.org/dt/search](https://www.typescriptlang.org/dt/search).

You may find that some packages are not up-to-date. I found [@types/gsap](https://www.npmjs.com/package/@types/gsap) to be incomplete. It does not include a definition for the `gsap` object. The [gsap npm package](https://www.npmjs.com/package/gsap) covers the entire API. So, you can install that as a dependency instead - `npm install --save-dev gsap`.

![intellisense](https://dev-to-uploads.s3.amazonaws.com/i/pf7v73y1tmispfrg0y7g.png)

One thing to note is that the type definitions don't provide IntelliSense inside `script` tags in your HTML file. There is an [open issue requesting this feature](https://github.com/microsoft/vscode/issues/26338). Hopefully, this will be resolved in the near future! 🤞

---
**You can subscribe to my [RSS feed](https://roboleary.net/feed.xml) to get my latest posts.**
***
Resources to crush the technical interview
Tags: career, codenewbie, github, aws
Published: 2020-12-28 09:23:33

Technical interviews are difficult. So I decided to gather resources that will help you crush your next interview.

### Let’s start!
 
## 1. Coding Interview University
A complete computer science study plan to become a software engineer.

Link: https://github.com/jwasham/coding-interview-university

## 2. JavaScript Algorithms
Algorithms and data structures implemented in JavaScript with explanations and links to further readings

Link: https://github.com/trekhleb/javascript-algorithms

## 3. Tech Interview Handbook
Materials to help you rock your next coding interview

Link: https://yangshun.github.io/tech-interview-handbook/

## 4. OG AWS
Amazon Web Services — a practical guide

Link: https://github.com/open-guides/og-aws

## 5. JavaScript Questions
A long list of (advanced) JavaScript questions, and their explanations.

Link: https://github.com/lydiahallie/javascript-questions

## 6. The System Design Primer
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

Link: https://github.com/donnemartin/system-design-primer

## 7. Interview
Everything you need to prepare for your technical interview.

Link: https://github.com/Olshansk/interview

## 8. Awesome Interviews
A curated awesome list of lists of interview questions.

Link: https://github.com/MaximAbramchuck/awesome-interview-questions

## 9. Interviews
Everything you need to know to get the job.

Link: https://github.com/kdn251/interviews

## 10. React Interview Questions & Answers
List of top 500 ReactJS Interview Questions & Answers.

Link: https://github.com/sudheerj/reactjs-interview-questions

## 11. Coding Interviews
This repository contains coding interviews that I have encountered in company interviews.

Link: https://github.com/jayshah19949596/CodingInterviews

## 12. Reverse interview
Questions to ask the company during your interview.

Link: https://github.com/viraptor/reverse-interview

## 13. Front end Interview Questions
Help the front End community to rock interview.

Link: https://thatjsdude.com/interview/

## 14. 70 JavaScript Interview Questions
Link: https://dev.to/macmacky/70-javascript-interview-questions-5gfi

## 15. Back-End Developer Interview Questions
A list of back-end related questions you can be inspired from to interview potential candidates, test yourself or completely ignore.

Link: https://github.com/arialdomartini/Back-End-Developer-Interview-Questions

Initially created on Twitter:
{% twitter 1343487437666971648 %}

If you liked this article, be sure to ❤️ it.

## Happy coding! ❤️
CSR? SSR? 그냥 적재적소에 써라!
Tags: javascript, ssr, korean
Published: 2020-12-28 09:06:19

자, CSR과 SSR 이 있다. 이 둘의 차이점은 기본적으로 알고 있을 거라 믿고 시작하겠다.
몰라? 화면 표현을 클라이언트에게 모두 전가하느냐, 아니면 서버가 어느정도 개입하느냐 그 차이잖아.

둘의 장단점이 있다면,

- CSR 장점
  - 정적 파일만 제공하는 웹 서버 게시가 가능해져 더 다양한 게시 제공자(특히 Github Pages)에 서비스가 가능하다.
  - 클라이언트와 서버의 경계가 명확해 확실한 업무분리가 가능하다.
- CSR 단점
  - 트래픽 유발이 많아진다 (그래서 캐시관리가 중요하지)
  - 클라이언트 환경에 따라 차이가 크다 (흔히 말하는 누군 되고 안되고)
- SSR 장점
  - 서버의 트래픽을 절약할 수 있다. (필요한 정보만 뿌리면 되니까)
  - SEO에 유리하다
- SSR 단점
  - 클라이언트와 서버의 경계가 모호하다 (거의 풀스택이 요구된다)
  - 정적 파일만 게시 가능한 제공자에 서비스가 불가능하다.

- CSR에 유리한 분야
  - 관리 패널같이 주제가 명확한 프로그램 (즉, 레이아웃이 거기서 거기라면 유리)
  - 모바일 웹앱과 같이 적은 리소스, 적은 템플릿으로 특정 장치에 동적 컨텐츠 제공하는 서비스
- SSR에 유리한 분야
  - 쇼핑몰, 뉴스 같이 컨텐츠 중심의 동적 페이지 기반 서비스
  - 검색 및 소셜 네트워크와 연동이 잦고 이들의 입지가 중요한 서비스

누가 CSR이 좋냐, SSR이 좋다 이딴 식으로 편애하는 글이 있으면 모두 다 씹고 내 제안 따라라. 모든 디자인 패턴은 각기 장단점이 있기 때문에 목적에 맞게 적재적소에 쓰는 것이 옳다. 세상에 완벽한 디자인 패턴은 존재하지 않는다는 것만 기억하라.

## SI인 경우 팁(?)
- 만약 관리 프로그램(ERP 등)에 SSR 한다는 아키 있다면 죽빵 갈기거나, 그 프로젝트를 나가는 게 정신건강에 좋다. 너에게 모든 걸 떠넘기겠다는 뜻이다. (node.js 로 mybatis 만들 자신 있다면 말리지 않겠다!?)
- 만약 대국민 서비스(포털 등)에 CSR 한다는 아키 있다면 싸다구 날리거나 프로젝트 튀는 게 니 미래에 좋다. 너를 시험하겠다는 뜻이다. (node.js와 css 자바 오라클까지 다 니꺼?!)
Laravel Cron: The Definitive Guide
Tags: webdev, laravel, tutorial, beginners
Published: 2020-12-30 13:37:43

---
title: Laravel Cron: The Definitive Guide
published: true
date: 2020-12-28 08:43:53 UTC
tags: webdev,laravel,tutorial,beginners
canonical_url: https://medium.com/swlh/laravel-cron-the-definitive-guide-b05cfb91a5af
---

[![](https://cdn-images-1.medium.com/max/1536/1*K8nxwwCS2gIJmxGL2_NZ-g.jpeg)](https://medium.com/swlh/laravel-cron-the-definitive-guide-b05cfb91a5af?source=rss-8b0955f01559------2)

So you wish to automate some tasks in your newly created application with Laravel, say you want to send out birthday messages, promotional…

[Continue reading on The Startup »](https://medium.com/swlh/laravel-cron-the-definitive-guide-b05cfb91a5af?source=rss-8b0955f01559------2)
GCP Cloud Run with Pulumi + Go
Tags: go, googlecloud, pulumi
Published: 2020-12-28 08:31:55

\#Pulumi blog shows how to setup Cloud Run using TypeScript. Here's the #Go variant of it.

Gist is at: https://gist.github.com/timoe/d633c0b09d2fd24335ef9cb40aedc67c

```
pulumi.Run(func(ctx *pulumi.Context) error {
		enableCloudRun, _ := projects.NewService(ctx, "EnableCloudRun", &projects.ServiceArgs{
			Service: pulumi.String("run.googleapis.com",),
			Project: pulumi.StringPtr(gcpConf.GetProject(ctx)),
		})

		_, err := cloudrun.NewService(ctx, "app-name",
			&cloudrun.ServiceArgs{
			
				Location: pulumi.String("a-region"),
				// ProjectId from pulumi
				Project: pulumi.StringPtr(gcpConf.GetProject(ctx)),
				Template: &cloudrun.ServiceTemplateArgs{
					Spec: &cloudrun.ServiceTemplateSpecArgs{
						
						ServiceAccountName: pulumi.String("e-mail-service-accout"),
						Containers: &cloudrun.ServiceTemplateSpecContainerArray{
							&cloudrun.ServiceTemplateSpecContainerArgs{
							
								Image: pulumi.String("the-image"),
								Envs: cloudrun.ServiceTemplateSpecContainerEnvArray{
									
									&cloudrun.ServiceTemplateSpecContainerEnvArgs{
										Name:  pulumi.String("KEY"),
										Value: pulumi.String("VALUE"),
									},
								},
							},
						},
					},
				}}, pulumi.DependsOn([]pulumi.Resource{enableCloudRun}))
		return err
	})

```
What kind of contact forms do you prefer?
Tags: watercooler, communication
Published: 2020-12-28 08:09:50

---
title: What kind of contact forms do you prefer?
published: true
description: 
tags: watercooler, communication
cover_image: https://colorlib.com/wp/wp-content/uploads/sites/2/ContactFrom_v10.jpg
---
The first option is to go minimal and leave just like a Twitter handle, email address, and phone on the site. This way the format of the conversation is been left purely to the visitor.

The other option is to use input forms, where the visitor can send an email without leaving the site. This way the site owner has the advantage to require specific fields, like name, email, phone, subject, and message.

Personally, I have never filled any of those mentioned in the 2nd case. 

I always like to start conversations directly from my own email or social media accounts. This way it's easier to track them and I feel more secure the message actually has been sent.

Which approach do you like better and why?
Alleviate, Daily Blog and Relaxation app
Tags: dohackathon, flutter, docker
Published: 2020-12-28 08:02:30

As human beings, we tend to vent out on the smallest of issues and even have a lot of mood swings. Hence, I decided to make Alleviate, a daily journal/blog app that would stay personally with you. Users can add their daily life, as a blog that would stay just personally with you. This could be shared with a therapist if you'd like and this would definitely help users overcome any sort of phobia or stress that you might be facing, as it would more likely for therapists to help you if you write it down as a blog or a journal while it's still fresh in your mind.

####Features:
* Users shall be greeted and displayed with a daily motivational quote. Though many people do not read such quotes, it is highly observed that it somehow does get in your head deep down, somewhere we all don't even realize and know.

* Users can set reminders if they like within the app, and they would be reminded 15 minutes prior to the actual time so that users are somewhat prepared mentally.

* Users can add their daily blogs, via text as well as also using their microphone. It is more likely observed that speaking your emotions out really helps in comparison to texting.

* Users also have the provision to add their daily mood, and statistical data will be generated based on the user's mood per week.

####Technologies:

The entire app will be developed on Flutter and Firebase for Google Sign-in and Cloud Firestore. For the voice recorder feature, Google Speech to Text API will be used, for faster and efficient conversion of speech into text.

##First Week

* The initial boilerplate code was recognized and analyzed along with the needs of API, tools, and the code.
* The login screen was ditched and replaced with a Sign-in Google feature for better user experience and better security.
* The blog part, along with the home screen and Speech to Text API was somewhat a tougher process, but however completed it within a week's time.

#### Stay tuned for next week's progress.
Risk and Entrepreneurs
Tags: entrepreneurs, risk, startup
Published: 2020-12-28 08:01:05

Risk factor!
Don't take risk blindly without analyzing. Now in recent entrepreneurs have "can do" attitude which drives them to take any risk thinking that we will never succeed in life until we take the risk. But it is not said anywhere else that who and all took risk they have succeeded in thiere work/life. Most of them fail because below pic is explaining that in very good manner.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kjpm83cuo8fufcyiutp5.jpg)

Image ref : Google images.So this articles it is not about to discourage the people who having entrepreneur potential inside them, it is them to decide where to take risk and decide is that risk will take them to a goal. Blind risk or without proper analysis risk can be a dangerous.


Now people thinks who will take risk blindly, we have analysed correctly but outcome is failure only. So some times it is adviced that take risk in your compfart zone means "IF risk got failed, it should not be a dangerous to your life, you must able to come out from that and should be able to take more risks freely".
Time management as a developer for maximum productivity.
Tags: beginners, python, javascript, webdev
Published: 2020-12-28 07:51:55

TIME MANAGEMENT is "key" as a developer who might be a student, father, wife, freelancer in a full time job etc. We are to code and develop in situations and conditions that surrounds us either good or bad, tense or calm, stressful or comfortable etc and we have 24 hours a day to bring out something meaningful from (an high level of productivity).

These are tips to help us out;

Have a plan and schedule your day activity,

Divide larger task into few smaller tasks,

Know your priorities,

Analyse daily tasks before bed time and note the downtime,

Cultivate discipline and

Limit distractions.
The Wide World of an entry-level developer
Published: 2020-12-26 08:56:47

Hello, my name is Anna, I am from New Zealand and I am starting out as a junior, full-stack web developer.
Before the Covid pandemic, I was a makeup artist and once all the productions were closed and we went into a month-long lockdown with no income, I knew I needed a stable career change.

My sister's friend did a web developer course that only lasted a couple of months which allowed her to find a job that she loves. She recommended the course and within a couple of weeks, I was enrolled in Dev Academy. A course that teaches you how to be a full-stack web developer in 15 weeks. 

We learned about:
- HTML 5
- CSS
- JavaScript
- React
- Redux
- API's
- Databases
- Testing

I will be honest, the course was physically, emotionally, and mentally challenging. I spent most days there, had to overcome my inner critic and work with people that I didn't necessarily bond with.

All in all, I'm excited to start my career as a web developer and I will be posting my journey here!


Until next time, Anna
Fix highlight.js does not work with page transition
Tags: react
Published: 2020-12-28 07:41:13

I was using `highlight.js` to add color to the code, but when I added page transition, it stopped working.

## 1. page transition

```tsx
const MyApp = () => {
  const router = useRouter();

  return (
    <GlobalPageTransition>
      <Component {...pageProps} key={router.route} />
    </GlobalPageTransition>
  );
};
```
In this way, `<GlobalPageTransition>` gave animation at page transition.

## 2. highlight

```tsx
const MyApp = () => {
  useHighlight();

  // ...
};
```

I use these hooks to automatically launch highlight.js.
WIthin this hooks, other than unmounting, is the process of giving highlight.

```tsx
useEffect(() => {
    let mounted = true;
    if (mounted) {
      // highlight processing
    }
    return () => {
      mounted = false;
    };
  });
```

However, if I add <GlobalPageTransition> to this process, the initial load does not work properly.

## 3. Solutions
It was highlighted by adding it inside the `[title].tsx` component instead of `_app.tsx`.

```tsx
const Post = () => {
  useHighlight();
  // ...
});
```
Top 5 CSS methodologies in 2021
Tags: css, methodologies, top
Published: 2020-12-28 07:36:27

Css is very difficult to manage when you are dealing with a large system, this is because Everything in css is Global...

Over the years developers have tried to proofer solution to this CSS maintainability problems, and this as led to many developers creating their own css methodologies...

<h1>What are css methodologies?</h1>

css methodologies are systems that are formaly documented down that help us to auhor/write css as isolated modules, rather than just some long indivisible code.

<h2> Top 5 CSS methodologies in 2021 </h2>
1. Atomic Css
2. BEM
3. ITCSS
4. SMACSS
5. OOCSS

Please note that this list is based on the survey from   <a href=" https://2020.stateofcss.com/en-US/technologies/methodologies/">The state of CSS 2020</a>

<h3> The Big Reveal </h3>
There is no <b>best CSS methodology</b>, The one you just to use depends on you and the type of your project.

This post was originally written here
<a href=" https://spruce.com.ng/blog/top-5-css-methodologies-in-2021.html">Top 5 CSS methodologies in 2021</a>
...