Skip to content

Instantly share code, notes, and snippets.

View donjajo's full-sized avatar
🏠
Working from home

James John donjajo

🏠
Working from home
View GitHub Profile
@donjajo
donjajo / myFirstGUI.py
Last active February 28, 2016 17:04
My First Python GUI Program :D
#!/usr/bin/python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import urllib2
class Form( QDialog ):
def __init__( self, parent = None ):
super( Form, self ).__init__( parent )
export function load_cat_names() {
return dispatch => {
return fetch( '/?token=' + vitals.token, {
method : 'POST',
headers : {
'X-Requested-With' : 'XMLHttpRequest'
},
body : JSON.stringify({ action : 'cat_names' }),
credentials : 'same-origin'
})
@donjajo
donjajo / wilfred_algorithm.php
Last active September 6, 2017 21:49
Wilfred's Algorithm in PHP
<?php
$you = 1;
$p = 2;
$f = [ $you, $p ];
// Random conversation
$conv = mt_rand( 0, 3 );
// At the beginning set the last date of conversation
$cur_date = '2017-02-06';
$x[ $p ][ $you ] = [ $cur_date => $conv ];
@donjajo
donjajo / s3_dirs.php
Last active October 2, 2018 18:14
Get List of Directories in AWS S3 as array keys. Nested subfolders
<?php
require_once( __DIR__ . '/aws/aws-autoloader.php' );
use Aws\S3\S3Client;
define( 'AWS_S3', [
'key' => '',
'secret' => '',
'bucket' => ''
]);
@donjajo
donjajo / datamap.react.js
Last active February 19, 2019 10:57
Reactjs Datamap wrapper
import React, { Component } from "react";
import { withScriptjs, withGoogleMap, GoogleMap, Marker } from "react-google-maps";
import Datamap from 'datamaps'
import API from '../../../../api/MapKey';
class Map extends Component {
constructor( props ) {
super( props )
this.state = {
<html>
<body>
<stream src="84d67cc5b2639fcbdc25cbc78b5f1268" controls preload autoplay loop mute></stream>
<script data-cfasync="false" defer type="text/javascript" src="https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=84d67cc5b2639fcbdc25cbc78b5f1268"></script>
<script>
var firstStreamElement = document.getElementsByTagName('stream')[0];
firstStreamElement.addEventListener( 'play', function( e ) {
e.target.currentTime = 3;
})
<?php
$numbers = [ 3,3,2,2,56,4,4 ];
$checked = [];
foreach( $numbers as $number ) {
$checked[ $number ] = !empty( $checked[ $number ] ) ? $checked[ $number ] + 1 : 1;
}
asort( $checked );
echo current( array_keys( $checked ) );
@donjajo
donjajo / array_pop.c
Last active April 12, 2019 21:03
Finds the non-repeated number in an array
#include <stdio.h>
#include <stdlib.h>
_Bool in_array();
int *pop_array();
void main() {
int numbers[] = { 1, 2, 2, 4, 4, 1, 5, 6, 5 };
int length = sizeof( numbers ) / sizeof( numbers[ 0 ] );
int lucky = 0;
@donjajo
donjajo / file_get_contents.c
Last active May 5, 2019 21:12
Replica of file_get_contents() function in PHP
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *file_get_contents();
int main() {
char *str = file_get_contents( "test.txt" );
printf( "%s", str );
free( str );
@donjajo
donjajo / list_files.c
Created May 15, 2019 12:43
List files in directory and sub directories with size and permission
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
void list_files();
void main( int argc, char * argv[] ) {
list_files( argv[1], 0 );