This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basic Select */ | |
-- Revising the Select Query I | |
SELECT | |
* | |
FROM | |
CITY | |
WHERE | |
POPULATION > 100000 | |
AND COUNTRYCODE = 'USA' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <string> | |
using namespace std; | |
bool isPrime(int num){ | |
if (num <= 1) return false; | |
for(int i = 2; i <= sqrt(num); i++){ | |
if (num % i == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
bool isPrime(int num){ | |
if (num <= 1) return false; | |
for(int i = 2; i <= sqrt(num); i++){ | |
if (num % i == 0) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func fibonacci() func() int { | |
fib1, fib2 := 0, 1 | |
return func() int{ | |
defer func() { fib1, fib2 = fib2, fib1 + fib2 } () | |
return fib1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
sArr := strings.Fields(s) | |
count := make(map[string]int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
pic := make([][]uint8, dy) | |
for i := range pic { | |
pic[i] = make([]uint8, dx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func Sqrt(x float64) float64 { | |
z := 1.0 | |
it := 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://morimori.tokyo/2015/10/adjusting-timestamps-from-a-gopro/ | |
# | |
#!/usr/bin/env bash | |
FILES=$(ls *.MP4) # FILES=$(ls *.{JPG,MP4}) | |
for filename in $FILES | |
do | |
# Offset is 974 days 10 hours 39 minutes | |
NEWDATE=$(date -j -v+974d -v+10H -v+39M -f "%m/%d/%Y %H:%M:%S" "$(GetFileInfo -m $filename)" +"%m/%d/%Y %H:%M:%S") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
/** | |
* 1.1 Implement an algorithm to determine if a string has all unique characters. | |
* What if you cannot use additional data structures? | |
* | |
* idea: Make a hash table to store the character. | |
* The key is the position of the char in the given string; | |
* The value is the char in the given string. | |
* By adding the char of the given string into the hash table, first check | |
* if the hash table has already contain the value(the particular char in String). |