Skip to content

Instantly share code, notes, and snippets.

View otnansirk's full-sized avatar
:octocat:
Coding

Kris otnansirk

:octocat:
Coding
View GitHub Profile
<?php
$dbh = new PDO('mysql:host=localhost;dbname=[your-database]', "[your-user]", "[your-password]");
//menampilkan data per-page nya                                                                                                       $perPage= 3;
// get page. mengambil nilai dari get page
$page = isset($_GET['page'])? (int)$_GET['page']:1;
@otnansirk
otnansirk / ajax.js
Created October 17, 2017 15:12
ajax.js
$.ajax({
url: "https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=e9717e4bd91642dabcdec078ea76c03e",
json: "callback",
dataType: "json",
success: function( response ) {
$.each(response.articles, function(i, data){
console.log(data); // server response
});
{
author: "Josiah Motley", title: "Steps you can take to help protect yourself from the next KRACK attack", description: "So, by now, you’ve probably heard of the KRACK vul… access to Wi-Fi networks through the core WPA2 …", url: "https://thenextweb.com/contributors/2017/10/17/steps-can-take-help-protect-next-krack-attack/", urlToImage: "https://cdn0.tnwcdn.com/wp-content/blogs.dir/1/files/2017/10/KRACK-main-tnw-social.jpg", …}
author : "Josiah Motley"
description : "So, by now, you’ve probably heard of the KRACK vulnerabilities and the announcement made through a website that credits Mathy Vanhoef of imec-DistriNet with the discovery. While, there is a lot of technical jargon, what is essentially happening with this vulnerability is that it gives people easy access to Wi-Fi networks through the core WPA2 …"
publishedAt : "2017-10-17T14:24:47Z"
title : "Steps you can take to help protect yourself from the next KRACK attack"
url : "https://thenextweb.com/contributors/2017/10/17/steps-can-take-help
Clone this :
git clone https://github.com/Anomareh/PHP-Twig.tmbundle.git
Selanjutnya
* buka sulime-text
* tekan ctrl+shif+p (linux,windows)
* ketik browser package lalu enter
* buat folder dengan nama PHP-Twig
* lalu buka package yang sudah didownlad tadi. pindahkan file yang ada di dalam DIR PHP-Twig.tmbundle/Syntaxes
kedalam folder PHP-Twig.
<input id="file" type="file">
<script>
document.getElementById("file").onchange = function() {
alert(document.getElementById("file").files[0]);
}
</script>
<!-- onchange ; mening when where is a change -->
@otnansirk
otnansirk / E: Sub-process returned an error code (1). when purge package
Last active May 26, 2018 02:25
Solve error . E: Sub-process /usr/bin/dpkg returned an error code (1). when purge package
sudo mv /var/lib/dpkg/info/{packagename}.* /tmp/
sudo dpkg --remove --force-remove-reinstreq {packagename}
sudo apt-get remove {packagename}
sudo apt-get autoremove && sudo apt-get autoclean
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
io.sockets.adapter.rooms["ROOM_NAME"].sockets
reference
https://stackoverflow.com/questions/35249770/how-to-get-all-the-sockets-connected-to-socket-io/35251958
@otnansirk
otnansirk / socket.io server.js
Last active August 7, 2019 01:39
socket.io with namespace, multiple socket.id and disconnect socket.id
var app = require('express')();
var http = require('http');
var httpServer = http.createServer(app);
var io = require('socket.io')(httpServer);
/**
* get unique data
*/
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
@otnansirk
otnansirk / Bujang anom bot - ReogDev
Last active September 7, 2021 01:43
pasttent@gmail.com
function doPost(e) {
var token = "873868937:AAFEeWnw-nebX6KFwHLKspDlZHPehwYcsbo";
var stringJson = e.postData.getDataAsString();
var updates = JSON.parse(stringJson);
var chatId = updates.message.chat.id;
var messageId = updates.message.message_id;