Skip to content

Instantly share code, notes, and snippets.

View mojenmojen's full-sized avatar

mojen mojenmojen

View GitHub Profile
@mojenmojen
mojenmojen / gist:0c7a3da3084211e649fdb21f1341df94
Created August 5, 2017 18:26
example of Ionic grid setup for buttons
<ion-grid>
<ion-row>
<ion-col>
<button ion-button margin (click)="pushPage(pages.menus.items[1])">SPORTS</button>
<button ion-button margin (click)="pushPage(pages.menus.items[2])">BUTTON2</button>
<button ion-button margin (click)="pushPage(pages.menus.items[3])">BUTTON3</button>
</ion-col>
<ion-col>
<button ion-button margin (click)="pushPage(pages.menus.items[4])">BUTTON4</button>
@mojenmojen
mojenmojen / gist:60eeb3da9b7b7668996530b3911c84b0
Created August 5, 2017 16:20
Apppresser default custom home page
<ion-grid>
<ion-row>
<ion-col col-6 *ngFor="let p of pages.menus.items" [ngClass]="p.extra_classes">
<ion-card (click)="pushPage(p)" class="menu-card">
<div class="card-title"><ion-icon *ngIf="p.class" name="{{p.class}}"></ion-icon></div>
<div class="card-subtitle">{{p.title}}</div>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
@mojenmojen
mojenmojen / add_login_logout_link.php
Created March 1, 2017 21:11
Add login/logout links to WP menus
@mojenmojen
mojenmojen / qs_login_redirect_custom.php
Created March 1, 2017 19:13
Wordpress Login Redirect to Custom Page
/* Main redirection of the default login page */
function qs_redirect_login_page() {
$login_page = home_url('login');
$page_viewed = basename($_SERVER['REQUEST_URI']);
if($page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
}
@mojenmojen
mojenmojen / qs_login_redirect.php
Created March 1, 2017 19:12
WordPress Login Redirect
/**
* Redirect user after successful login.
*
* @param string $redirect_to URL to redirect to.
* @param string $request URL the user is coming from.
* @param object $user Logged user's data.
* @return string
*/
function qs_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
@mojenmojen
mojenmojen / countClusters.sc
Created December 8, 2016 18:41
Count Possible Clusters
public static int CountPossibleClusters( int totalRelics, int checkNum ) {
int next_checkNum = 0;
switch (checkNum) {
case 6:
next_checkNum = 5;
break;
case 5:
next_checkNum = 4;
break;
@mojenmojen
mojenmojen / multi_array_sum.js
Created September 26, 2016 01:46
Write a method multi_array_sum to find (and return) the sum of all the numbers in a multi-dimensional array of integers.
/*
Write a method multi_array_sum to find (and return) the sum of all the numbers in a
multi-dimensional array of integers. A multi-dimensional array is an array for which
at least some elements are themselves arrays. In this example every array and sub-array
will only contain integers and/or more sub-arrays.
SAMPLE OUTPUT
Given a multi-dimensional array:
a = [1, [2, [3,4]], [5,6] ]
@mojenmojen
mojenmojen / check_divisors.js
Created September 26, 2016 01:06
Define a method called check_divisors that takes three parameters, divisor_array (an Array) and low and high will be integers. The method should print all numbers from low to high; if any number being printed is divisible by any divisor number in divisor_array, print the number + the word "one_match". If the number being printed is divisible by …
/*
sample output:
if the function call were check_divisors( [2,3], 1, 7) the printed output would be:
1
2 one_match
3 one_match
4 one_match
5
@mojenmojen
mojenmojen / clock_angles.js
Created September 26, 2016 00:39
Write a method that returns the degree of the angle formed by the two hands of the clock at any given time, to the nearest integer. Remember a circle has 360 degrees. The hour and minute variable are passed in as integers. Note that "the angle between the hands" implies a few things, some or all of which might be tested: 1. we don't care if the …
function clock_angles(hour, minute) {
// note: there are 360 degrees around the clock interface
// calculate the degree position of the hour hand
hourDegree = 30 * hour;
// calculate how far the hour hand is from zero
if ( hourDegree < 180 ) {
hourDifference = hourDegree;
@mojenmojen
mojenmojen / reversearray.js
Created September 25, 2016 19:24
For this exercise, write two functions, reverseArray and reverseArrayInPlace. The first, reverseArray, takes an array as argument and produces a new array that has the same elements in the inverse order. The second, reverseArrayInPlace, does what the reverse method does: it modifies the array given as argument in order to reverse its elements. N…
function reverseArray( arrayToInvert ) {
// create a variable for the new array
var invertedArray = [];
// count how many things are in the original array
numLoops = arrayToInvert.length;
// loop that many times backwards and put each element into the new array
for ( i = numLoops -1; i >= 0; i-- ) {
invertedArray.push( arrayToInvert[i]);