Skip to content

Instantly share code, notes, and snippets.

@fakeheal
fakeheal / PHP: Highly divisible triangular number.php
Last active April 14, 2016 07:48
PHP: Highly divisible triangular number (ProjectEuler Problem #12)
<?php
function countDivisors($number)
{
$count = 0;
$sqrtOfNumber = (int)sqrt($number);
for($i = 1; $i <= $sqrtOfNumber; $i++)
{
if($number % $i == 0)
$count += 2;
@fakeheal
fakeheal / PHP: Large sum.php
Last active August 29, 2015 14:08
PHP: Large sum - ProjectEuler Problem #13
<?php
$new = explode("\n", $number);
$sum = 0;
foreach($new as $n){
$sum += trim($n);
}
echo $sum;
@fakeheal
fakeheal / PHP: Longest Collatz sequence.php
Last active August 29, 2015 14:08
PHP: Large sumLongest Collatz sequence - ProjectEuler Problem #14
<?php
function sequence($start, $step = 0)
{
while($start != 1)
{
if($start % 2 == 0)
$start = $start / 2;
else
$start = 3*$start + 1;
$step++;

Keybase proof

I hereby claim:

  • I am FakeHeal on github.
  • I am fakeheal (https://keybase.io/fakeheal) on keybase.
  • I have a public key whose fingerprint is D80B 9BFB 5FD6 2E5B 4EB7 D9D6 09A9 E966 1025 B732

To claim this, I am signing this object:

@fakeheal
fakeheal / exec
Created April 14, 2016 07:45
Get invalid recipient's emails from mailgun
php logs.php > logs.txt
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class CategoryProductTable extends Seeder
{
/**
* Run the database seeds.
@fakeheal
fakeheal / file.js
Created March 16, 2018 15:31
How to get 1000 score in Got Rhythm (https://www.concerthotels.com/got-rhythm)
setInterval(function() { $("#canvas").click(); }, 500);
@fakeheal
fakeheal / file.js
Last active January 11, 2020 12:58
Easily unfollow people on last.fm
/**
* Open console and paste the following code.
*
* If you have multiple pages with people you're following,
* wait for the page to refresh and the press on your keyboard:
* ARROW UP + ENTER.
*
* This will execute the two lines above, unfollowing the people from the page.
*/
@fakeheal
fakeheal / RescueTime Productivity Time.scpt
Last active February 26, 2020 13:59
AppleScript for returning total productivity time for the current day tracked by Rescue Time
tell application "JSON Helper"
-- Set your api key here
-- You can get it at: https://www.rescuetime.com/anapi/manage
set rescuetime_api_key to ""
set {year:y, month:m, day:d} to (current date)
set today to y & "-" & m & "-" & d
set rescuetime to fetch JSON from "https://www.rescuetime.com/anapi/data?key="& rescuetime_api_key &"&format=json&restrict_begin=" & today & "&restrict_end=" & today
set rows to rows of rescuetime as list
@fakeheal
fakeheal / App.tsx
Created May 17, 2021 10:41
Example: Request read/write Steps and Query Data
import React, { useState } from 'react'
import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, View } from 'react-native'
import { Colors } from 'react-native/Libraries/NewAppScreen'
import AppleHealthKit, { HealthKitPermissions, HealthValue } from 'react-native-health'
/* Permission options */
const permissions = {
permissions: {
read: [AppleHealthKit.Constants.Permissions.Steps],