This file contains hidden or 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 { SupabaseClient } from "https://esm.sh/@supabase/supabase-js@2.7.1"; | |
| import { rgbaToThumbHash } from "https://esm.sh/thumbhash@0.1.1"; | |
| import { Image, decode } from "https://deno.land/x/imagescript@1.3.0/mod.ts"; | |
| import * as base64 from "https://denopkg.com/chiefbiiko/base64/mod.ts"; | |
| async function generateBase64ThumbHash( | |
| data: ArrayBuffer, | |
| ): Promise<string> { | |
| const image = await decode(new Uint8Array(data)) as Image; | |
| image.resize(100, 100); |
This file contains hidden or 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 androidx.lifecycle.* | |
| import io.reactivex.Flowable | |
| /** | |
| * Description: | |
| * Observe LiveData with LifecycleOwner. | |
| * Usage: | |
| * observe(viewModel.liveData) { | |
| * it ?: return@observe |
This file contains hidden or 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
| let arr = [1,2,3,4,5,6]; | |
| let even = arr.filter(element => { | |
| return element % 2 === 0; | |
| }); | |
| // Result: even = [2,4,6] |
This file contains hidden or 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
| let newArr = oldArr.filter(callback); |
This file contains hidden or 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
| let newArr = oldArr.filter(callback); |
This file contains hidden or 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
| let arr = [1, 2, 3, 4, 5, 6]; | |
| let even = []; | |
| for(var i = 0; i < arr.length; i++) { | |
| if (arr[i] % 2 === 0) even.push(arr[i]); | |
| } | |
| // Result: even = [2,4,6] |
This file contains hidden or 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
| let plus5 = arr.map((element) => { | |
| return element + 5; | |
| }); | |
| // Result: plus5 = [6,7,8,9] |
This file contains hidden or 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
| let newArr = oldArr.map((element, index, arr) => { | |
| // return element to new Array | |
| }); |
This file contains hidden or 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
| const arr = [1, 2, 3, 4]; | |
| let plus5 = []; | |
| for(var i = 0; i < arr.length; i++) { | |
| plus5[i] = arr[i] + 5; | |
| } | |
| //OR WITH FOREACH SYNTAX | |
| arr.forEach((element, index) => { | |
| plus5[index]= element + 5 |
This file contains hidden or 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
| function numOfArgs(...theArgs) { | |
| console.log(theArgs.length); | |
| } | |
| numOfArgs(); //logs: 0 | |
| numOfArgs(5); //logs: 1 | |
| numOfArgs(5, 6, 7); //logs: 3 |
NewerOlder