Skip to content

Instantly share code, notes, and snippets.

View dmk1111's full-sized avatar
🐢
Working

Dmytro Holysh dmk1111

🐢
Working
View GitHub Profile
@dmk1111
dmk1111 / *.md
Created September 12, 2017 10:09
Component versus Directive in AngularJS

Component versus Directive in AngularJS

.component()

Components are not "helper" methods, they are the best change in Angular 1.x since I've been using it.

What is the role of .component()?

  • Declares new HTML via a template or templateUrl
  • Should be used to create Components as part of a Component architecture
@dmk1111
dmk1111 / Random-string
Created November 9, 2017 18:57 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@dmk1111
dmk1111 / node-ubuntu-upstart-service.md
Created November 16, 2017 08:47 — forked from willrstern/node-ubuntu-upstart-service.md
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@dmk1111
dmk1111 / Google-Sheet-Form-Post.md
Created November 16, 2017 12:35 — forked from willpatera/Google-Sheet-Form-Post.md
Post to google spreadsheet from html form

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Run example

You should be able to just open index.html in your browser and test locally.

However if there are some permissions errors you can make a quick html server with python. Open terminal and cd to the directory where the gist files are located and enter python -m SimpleHTTPServer. By default this creates a local server at localhost:8000

@dmk1111
dmk1111 / angularjs-get-injector.js
Last active April 24, 2018 11:28
get angular service from console
var injector = angular.element(document.querySelector('*[ng-app]')).injector();
var myService = injector.get("myService");
// You can call service methods from console now
//info taken this question: from https://stackoverflow.com/questions/15527832/how-can-i-test-an-angularjs-service-from-the-console
@dmk1111
dmk1111 / git-tag-delete-local-and-remote.sh
Created June 20, 2018 11:09 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@dmk1111
dmk1111 / postgres-brew.md
Last active June 23, 2018 07:55
Installing Postgres via Brew (OSX) (outdated see top most note)

Outdated note: the process is a lot easier now: after you brew install postgresql you can initialize or stop the daemon with these commands: brew services start postgresql or brew services stop postgresql.

new out put may look like

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
@dmk1111
dmk1111 / ng6-directives-interceptor.md
Last active September 17, 2018 07:35
Example of using Angular 2+ (Angular 6) directive as input interceptor

Directives can be used as interceptors on the input before the model changes. Here is an example of such a directive:

@Directive({
	selector: '[myValueChangeInterceptor]',
	providers: [NgModel]
})
export class InputInterceptorDirective {
	@Input() public myValueChangeInterceptor: (value: string) => string;
	@Output() public valueInput: EventEmitter<string> = new EventEmitter();
@dmk1111
dmk1111 / ng6-templates.md
Created September 17, 2018 10:00
Example of using Angular 2+ (Angular 6) templates with Material Dialog popup

Our team had interesting case with material dialog. We are working on common components, that are used by other teams and our goal is to simplify the development process. The problem was that the material dialogue does not support transclude (<ng-content>). To solve the problem created a separate DialogContentComponent, that is passed into

    this.dialogRef = this.dialog.open(DialogContentComponent, {disableClose: true})

that is inside of DialogComponent. DialogContentComponent has a template of the dialog, which should be everywhere the same, and in DialogComponent template we have only this:

{
"data": [
{
"id": 447365,
"title": "Guardians of the Galaxy Vol. 3",
"tagline": "",
"vote_average": 0,
"vote_count": 9,
"release_date": "2020-05-01",
"poster_path": "https://image.tmdb.org/t/p/w500/ldoY4fTZkGISMidNw60GHoNdgP8.jpg",