Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

James John donjajo

🏠
Working from home
Block or report user

Report or block donjajo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@donjajo
donjajo / id.c
Created Jun 13, 2019
Simple replica of `id` command
View id.c
#include <stdio.h>
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <grp.h>
#include <string.h>
void main( int argc, char *argv[] ) {
struct passwd *user;
struct group *group;
@donjajo
donjajo / list_files.c
Created May 15, 2019
List files in directory and sub directories with size and permission
View list_files.c
#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 );
@donjajo
donjajo / file_get_contents.c
Last active May 5, 2019
Replica of file_get_contents() function in PHP
View file_get_contents.c
#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 / array_pop.c
Last active Apr 12, 2019
Finds the non-repeated number in an array
View array_pop.c
#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;
View rusty.php
<?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 ) );
View steam.html
<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;
})
@donjajo
donjajo / datamap.react.js
Last active Feb 19, 2019
Reactjs Datamap wrapper
View datamap.react.js
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 = {
@donjajo
donjajo / s3_dirs.php
Last active Oct 2, 2018
Get List of Directories in AWS S3 as array keys. Nested subfolders
View s3_dirs.php
<?php
require_once( __DIR__ . '/aws/aws-autoloader.php' );
use Aws\S3\S3Client;
define( 'AWS_S3', [
'key' => '',
'secret' => '',
'bucket' => ''
]);
@donjajo
donjajo / wilfred_algorithm.php
Last active Sep 6, 2017
Wilfred's Algorithm in PHP
View wilfred_algorithm.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 ];
View shit.php
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'
})
You can’t perform that action at this time.