Skip to content

Instantly share code, notes, and snippets.

View awave1's full-sized avatar

Artem Golovin awave1

  • Vancouver, Canada
  • 09:27 (UTC -07:00)
View GitHub Profile
@awave1
awave1 / sum.js
Last active December 27, 2019 20:19
function sum(arr, i, j) {
return arr.slice(i, j).reduce((prev, current) => current += prev, 0);
}
console.log(sum([1, 2, 3, 4, 5], 1, 3));
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.shim.catalina.captivenetworkassistant.plist</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>

CPSC 501: Final Review

Q1: Refactoring

  • Code smell (from listing, off name)
  • Refactoring (official name, from listing)
  • Make 4 changes
    • has to be 4 separate changes
    • don’t change all at once
  • Same list of smells and refactoring are given
[{"topic":"weather","data":[-29.85092273691336]},{"topic":"weather","data":[34.127802211757185]},{"topic":"weather","data":[39.73724969905507]},{"topic":"weather","data":[17.708340534620127]},{"topic":"weather","data":[43.671826418041306]},{"topic":"weather","data":[-8.885247606175724]},{"topic":"weather","data":[-14.288513120383419]},{"topic":"weather","data":[-14.938803769871123]},{"topic":"weather","data":[-29.553742810153057]},{"topic":"weather","data":[33.03236732854032]},{"topic":"weather","data":[20.4762743473849]},{"topic":"weather","data":[-9.955597861605064]},{"topic":"weather","data":[7.693499175468759]},{"topic":"weather","data":[18.40701151261424]},{"topic":"weather","data":[-26.311356109832218]},{"topic":"weather","data":[38.12609281914723]},{"topic":"weather","data":[12.558345064581722]},{"topic":"weather","data":[-13.631466535459243]},{"topic":"weather","data":[-19.823479889164396]},{"topic":"weather","data":[-26.420139545205586]},{"topic":"weather","data":[-22.10232779768183]},{"topic":"weath
#!/usr/bin/env node
const fs = require('fs');
/**
* Simple script to generate random data for our mongodb
* example:
* node generate.js <topic_name> <min> <max> <numEntries>
*
* # or
<activity ...>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<!--
The line below specifies where to display the application.
In the regular application, the value would be "android.intent.category.MAIN"
-->
<category android:name="android.intent.category.INFO"/>
</intent-filter>
</activity>
#!/usr/bin/env python2
import struct
pad = 'a' * 96
addr = struct.pack('L', 0xreturn_addr + 50)
nops = '\x90' * 100
shellcode = "copy it here"
print pad + addr + nops + shellcode
// UIColor+HexString.h
#import <UIKit/UIColor.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIColor (HexString)
+ (UIColor *) colorWithHexString: (NSString *) hexString;
+ (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length;
if (!isLoaded()) {
var interval = setInterval(function () {
if (isLoaded()) {
clearInterval(interval);
loaded = true;
$(Event).trigger('loaded');
}
}, 10);
} else {
loaded = true;
<body>
<button id="btn">show answers</button>
<script>
var btn = document.getElementById('btn');
var body = document.body;
btn.onclick = function (event) {
body.insertAdjacentHtml('afterend', '<p>some paragraph</p>');
};
</script>
</body>