Skip to content

Instantly share code, notes, and snippets.

View vteivans's full-sized avatar

Viesturs Teivāns vteivans

View GitHub Profile
@vteivans
vteivans / git-publish.sh
Created December 6, 2024 15:15
Publishes the current git branch to remote named "origin"
#!/bin/sh
current_branch=$(git symbolic-ref --short -q HEAD)
if [ -z "$current_branch" ]; then
echo "No Current git branch found. Maybe not in a git repo?"
exit 1
fi
remote_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
if [ -n "$remote_branch" ]; then
@vteivans
vteivans / line.effect.ts
Last active January 31, 2019 12:44
Simple ngrx effect example with `withLatestFrom` operator for blog post: https://medium.com/@viestursv/how-to-get-store-state-in-ngrx-effect-fab9e9c8f087#.oekqp1ucb
import { Store, Action } from '@ngrx/store';
import { Actions, Effect } from '@ngrx/effects';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/withLatestFrom';
import { ADD_LINE } from './lines.reducer';
import { INC_PAGE_COUNT } from './pages.reducer';
import { AppState } from './app.store';
import { Action } from '@ngrx/store';
import { Actions, Effect } from '@ngrx/effects';
import 'rxjs/add/operator/map';
import { ADD_LINE } from './lines.reducer';
import { INC_PAGE_COUNT } from './pages.reducer';
@Injectable()
import { Action, ActionReducer } from '@ngrx/store';
interface Lines extends Array<string> {};
export const ADD_LINE = 'ADD_LINE';
export const linesReducer:ActionReducer<Lines> = (lines:Lines = [], action:Action) => {
switch (action.type) {
case ADD_LINE:
@vteivans
vteivans / TypeScriptNG.sublime-syntax
Created October 25, 2016 10:14
Basic Support for template string highlight in Agular 2 for Sublime Text 3 using Type Script. Created from this: https://gist.github.com/subhaze/a754c8d17906f2a25ce2
%YAML1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: TypeScript NG
file_extensions:
- ts
- ng.ts
scope: source.ts.ng
contexts:
main:
@vteivans
vteivans / gist:8024300
Created December 18, 2013 15:32
Programmēšanas spēle, atbildes uz jautājumiem
<?
if (!empty($_GET['q'])) {
$q = strtolower($_GET['q']);
if (strpos($q, 'what is your name') !== false) {
name();
} elseif (strpos($q, 'nice to meet you') !== false) {
myName($q);
} elseif (strpos($q, 'what was my name') !== false) {