Skip to content

Instantly share code, notes, and snippets.

View RagingLeviathan's full-sized avatar
🎯
Focusing

Murking Honchrows RagingLeviathan

🎯
Focusing
View GitHub Profile
@Jengas
Jengas / index.php
Last active February 11, 2025 18:05
Discord oauth2 example PHP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes. In case if your CURL is slow and is loading too much (Can be IPv6 problem)
error_reporting(E_ALL);
define('OAUTH2_CLIENT_ID', '1234567890');
define('OAUTH2_CLIENT_SECRET', 'verysecretclientcode');
@zcaceres
zcaceres / Revealing-Module-Pattern.md
Last active April 2, 2025 11:56
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

<?php
class authentication {
public function login($username, $password) {
$decrypted = $this->decrypt($password);
if($this->valid_password($username, $decrypted)) {
return true;
}
return false;
<?php
$category = 8;
$data = array(
164, 150, 132, 144, 125, 149, 145, 146,
158, 140, 147, 136, 148, 152, 144, 168,
126, 138, 176, 163, 119, 154, 165, 146,
173, 142, 147, 135, 153, 140, 135, 161,
145, 135, 142, 150, 156, 145, 128, 157
);
$min = min($data);
@bendo01
bendo01 / join_in_controller.php
Created May 17, 2013 10:00
using join with cakephp 2.x
<?php
/*
$tempx = $this->TranAktivitasKuliahMahasiswa->query("SELECT TranAktivitasKuliahMahasiswa.id, TranAktivitasKuliahMahasiswa.kode_kuliah_mahasiswa, TmstMahasiswa.nim, TmstMahasiswa.nama_mahasiswa
FROM tran_aktivitas_kuliah_mahasiswa AS TranAktivitasKuliahMahasiswa, tmst_mahasiswa AS TmstMahasiswa
WHERE TmstMahasiswa.id = TranAktivitasKuliahMahasiswa.tmst_mahasiswa_id AND TmstMahasiswa.tmst_program_studi_id = 2 or TmstMahasiswa.nim LIKE '%D42108%'", false);
*/
/*
$tempx = $this->TranAktivitasKuliahMahasiswa->query('SELECT TranAktivitasKuliahMahasiswa.id, TmstMahasiswa.nim, TmstMahasiswa.nama_mahasiswa
FROM tran_aktivitas_kuliah_mahasiswa AS TranAktivitasKuliahMahasiswa, tmst_mahasiswa AS TmstMahasiswa
WHERE TmstMahasiswa.id = TranAktivitasKuliahMahasiswa.tmst_mahasiswa_id AND TmstMahasiswa.tmst_program_studi_id = 58', false);