程序員如何在工作后找到女朋友?(文末有彩蛋)
生活中我們常常發(fā)現(xiàn)很多程序員拿著高薪,卻常常淪為單身狗,每當(dāng)情人節(jié)來臨,卻只能形單影只的一個(gè)人,過得十分凄慘。
自從程序員畢業(yè)出來工作進(jìn)入 IT 行業(yè)之后,常常接觸不到女性,一不小心就到了被催戀催婚的年紀(jì)。
前有阿里的高級工程師,穿著一雙特步的運(yùn)動鞋去相親,結(jié)果被對方婉拒。后有某程序員自爆去相親,卻帶著相親對象吃 79 塊的肯德基,結(jié)果回去后就被妹子拉黑了。
程序員們常常是大家調(diào)侃的對象,是因?yàn)樗麄兠刻炫c機(jī)器為伍,和電腦打交道,給人們留下的印象是宅,木訥,不善交流......
據(jù)說世界上有 2 種程序猿,一種是有女朋友的程序猿,另一種是不知道別的程序猿是怎么找到女朋友的程序猿。
那些有女朋友的程序員都是怎么找到女朋友的呢?讓我們一起來看下網(wǎng)友們怎么說。
程序員如何在工作后找到女朋友?
@知乎 小醬油
@知乎 楊锘
@知乎 程序員大叔
@知乎 禹程
@知乎 卡拉迦迪斯
其實(shí),除了宅,近乎完美的高薪程序員為什么會至今單身呢?這個(gè)問題一直沒找到一個(gè)合理的解釋。那么,就先讓我們一起來看下面這個(gè)故事!
程序員們?yōu)槭裁床蛔放耍?/strong>
程序員們?yōu)槭裁床蛔放???dāng)然是因?yàn)?,女朋友哪有代碼好看,女朋友哪有基友懂我,女朋友老管我,為什么要有女朋友。
對不起我撒謊了,為什么撒謊,容我先講個(gè)故事。
3 個(gè)月前,我發(fā)送了一個(gè)請求給一見鐘情的姑娘,沒想到她很快地響應(yīng)了數(shù)據(jù)。
在交互了一個(gè)月,傳遞了一些參數(shù)后,最終我鼓起勇氣,發(fā)送一個(gè)新請求。
沒有響應(yīng),再次請求,再三請求,她還是響應(yīng)了個(gè) 404,我覺得我的路徑有問題。
能 ping 得通,就是訪問不了,怪事!于是我決定使用閨蜜這個(gè)代理服務(wù)器,閨蜜建議我換參數(shù),比如某款香水。
這次立即給我響應(yīng)了,登上主頁面提示我提交數(shù)據(jù),她則返回了空結(jié)果作為響應(yīng),于是我傳了更多的參數(shù),并再一次發(fā)出了請求。
這次她顯示權(quán)限不足,依然 404。我找了基友,幫忙一起找 Bug,但在找我的 Bug 過程中,發(fā)現(xiàn)有好幾個(gè)人同時(shí)在給她發(fā)請求,但都得到響應(yīng)了。
有的甚至已經(jīng)開通白名單,原來 Server 端并不是不能處理并發(fā),而是直接忽略了我的請求。
最后我恍然大悟,原來是 CPU、顯卡性能不夠,只能當(dāng)備用,怪不得頻頻響應(yīng)數(shù)據(jù),接受參數(shù),卻一個(gè)功能都用不了。
最終我花了差不多 10K,但我意識到該及時(shí)止損了,最后當(dāng)我狠心卸載的時(shí)候,她還百般挽留,讓我對服務(wù)進(jìn)行評價(jià)...
過幾天,別人建議我試試訪問閨蜜這個(gè)代理地址,傳遞同樣的參數(shù),說不定就通了,性能更優(yōu)。但我沒有這么做,因?yàn)榧词乖谶@炮火連天的社會,我也不想變成,女生口誅筆伐的渣男。
幸運(yùn)的是,我沒有等到“我一直把你當(dāng)朋友啊”這個(gè)觸發(fā)事件才終止請求,但最終因才疏學(xué)淺,無法處理這種高并發(fā)問題,更不能保證線程安全,在考慮到時(shí)間、空間,及個(gè)人精力問題后,只能選擇放棄。
前幾天,突然看到了一條朋友圈,一位擁有著萌萌頭像的姑娘說:“為什么男生總是追到一半就不追了?”
What?一半?你特么給個(gè)進(jìn)度條???怎么會有女生覺得自己就應(yīng)該一直被追到底啊?!對不起,這種事情對被追求者來說是一半,對追求者來說是已經(jīng)結(jié)束了。
你不喜歡我,我心里不承認(rèn),你嘴上不承認(rèn)后來我想明白了,我并不欠你的。
我并不想因?yàn)榇煺劬蛯W(xué)套路,因?yàn)楹芏嗍虑楦嬖V我,世界上最可愛最打動人心的都是那些傻逼,而不是那些牛逼(pi)。
身邊的程序員,都是老實(shí)孩子,我們是有點(diǎn)積蓄,但不想當(dāng)提款機(jī),我付出了真心,也希望收獲真心。
如果你不喜歡我,請直接告訴我,我沒有比特幣,更沒有 208 萬,和你來一次壯志凌云地告別,但我依然相信愛情,只希望,遇見你,就是你!
看完上述這個(gè)故事,你有何感想?程序員可能是這個(gè)世界上“直男癌” 患者最多的群體之一吧。
但是……你真當(dāng)他們木訥、死板、死宅、不懂浪漫?開什么玩笑!在 520 之際,小編特地收集了這個(gè)程序員專屬的告白方式與大家分享,一起看看程序員用代碼敲出的浪漫吧~
程序員的小浪漫----煙火
完整項(xiàng)目預(yù)覽地址:http://lingyouhuiquanla.com/lover/
屬性設(shè)計(jì)
煙花應(yīng)有的三個(gè)狀態(tài)狀態(tài):
- 升空
- 等待炸裂
- 炸裂后
煙花:發(fā)射點(diǎn)(x,y),爆炸點(diǎn)(xEnd,yEnd),升空后等待炸裂時(shí)間(wait),炸裂后微粒個(gè)數(shù)(count),煙花半徑(radius)
煙花炸裂后微粒:自身位置(x,y),自身大?。╯ize),自身速度(rate),最大煙花半徑(radius)。
config:為全局變量,以及控制參數(shù),包括畫布寬高,設(shè)定煙花屬性等。
設(shè)定全局變量
- const config = {
- width: 360,
- height: 600,
- canvases: ['bg', 'firework'],
- skyColor: '210, 60%, 5%, 0.2)',
- fireworkTime:{min:30,max:60},
- //煙花參數(shù)本身有默認(rèn)值 傳入undefined則使用默認(rèn)參數(shù)
- fireworkOpt:{
- x: undefined,
- y: undefined,
- xEnd: undefined,
- yEnd: undefined,
- count: 300, //炸裂后粒子數(shù)
- wait: undefined, //消失后 => 炸裂 等待時(shí)間
- }
- }
構(gòu)建微粒類
- class Particle{
- //默認(rèn)值寫法
- constructor({x, y, size = 1, radius = 1.2} = {}){
- this.x = x;
- this.y = y;
- this.size = size;
- this.rate = Math.random(); //每個(gè)微粒移動的速度都是隨機(jī)不同的
- this.angle = Math.PI * 2 * Math.random(); //每個(gè)微粒的偏移角度
- //每次微粒移動速度分解為橫縱坐標(biāo)的移動。
- this.vx = radius * Math.cos(this.angle) * this.rate;
- this.vy = radius * Math.sin(this.angle) * this.rate;
- }
- go(){
- this.x += this.vx;
- this.y += this.vy;
- this.vy += 0.02; //重力影響 y越大實(shí)際越偏下
- //空氣阻力
- this.vx *= 0.98;
- this.vy *= 0.98;
- }
- //畫出微粒的位置
- render(ctx){
- this.go();
- ctx.beginPath();
- ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2, false);
- ctx.fill();
- }
- }
構(gòu)建煙花類
- class Firework{
- constructor({x, y = config.height, xEnd, yEnd, count = 300, wait} = {}){
- //煙花自身屬性
- this.x = x || config.width / 8 + Math.random() * config.width * 3 / 4;
- this.y = y;
- this.xEnd = xEnd || this.x;
- this.yEnd = yEnd || config.width / 8 + Math.random() * config.width * 3 / 8;
- this.size = 2;
- this.velocity = -3;
- this.opacity = 0.8;
- this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
- this.wait = wait || 30 + Math.random() * 30;
- //微粒個(gè)數(shù)等
- this.count = count;
- this.particles = [];
- this.createParticles();
- this.status = 1;
- }
- //創(chuàng)建微粒
- createParticles(){
- for(let i = 0;i < this.count; ++i){
- this.particles.push(new Particle({x:this.xEnd, y:this.yEnd}));
- }
- }
- //升空
- rise(){
- this.y += this.velocity * 1;
- this.velocity += 0.005; //升空時(shí)產(chǎn)生的阻力
- //煙花升空到目標(biāo)位置開始漸隱
- if(this.y - this.yEnd <= 50){
- this.opacity = (this.y - this.yEnd) / 50;
- }
- //如果到了目標(biāo)位置 就開始第二個(gè)狀態(tài)
- if(this.y <= this.yEnd){
- this.status = 2;
- }
- }
- //渲染煙花 煙花所有動作完成之后返回false
- render(ctx){
- switch(this.status){
- case 1: //升空
- ctx.save();
- ctx.beginPath();
- ctx.globalCompositeOperation = 'lighter';
- ctx.globalAlpha = this.opacity;
- ctx.translate(this.x, this.y);
- ctx.scale(0.8, 2.3);
- ctx.translate(-this.x, -this.y);
- ctx.fillStyle = this.color;
- ctx.arc(this.x + Math.sin(Math.PI * 2 * Math.random()) / 1.2, this.y, this.size, 0, Math.PI * 2, false);
- ctx.fill();
- ctx.restore();
- this.rise();
- return true;
- break;
- case 2: //煙花消失階段,等待炸裂
- if(--this.wait <= 0){
- this.opacity = 1;
- this.status = 3;
- }
- return true;
- break;
- case 3: //炸裂之后 渲染煙花微粒
- ctx.save();
- ctx.globalCompositeOperation = 'lighter';
- ctx.globalAlpha = this.opacity;
- ctx.fillStyle = this.color;
- for(let i = 0;i < this.particles.length;++i){
- this.particles[i].render(ctx);
- }
- ctx.restore();
- this.opacity -= 0.01;
- return this.opacity > 0;
- break;
- default:
- return false;
- }
- }
- }
放煙花
- const canvas = {
- init: function(){
- //一些屬性的設(shè)定 可以不用管
- this.setProperty();
- this.renderBg();
- //循環(huán)體 **主要
- this.loop();
- },
- setProperty: function(){
- this.fireworks = [];
- this.width = config.width;
- this.height = config.height;
- this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
- this.bgCtx = document.querySelector('#bg').getContext('2d');
- this.fireworkCtx = document.querySelector('#firework').getContext('2d');
- },
- renderBg(){
- this.bgCtx.fillStyle = 'hsla(210, 60%, 5%, 0.9)'
- this.bgCtx.fillRect(0, 0, this.width, this.height);
- },
- loop(){
- requestAnimationFrame(this.loop.bind(this));
- this.fireworkCtx.clearRect(0, 0, this.width, this.height);
- //隨機(jī)創(chuàng)建煙花
- if(--this.fireworkTime <= 0){
- this.fireworks.push(new Firework(config.fireworkOpt));
- //每次到點(diǎn)之后重新設(shè)置煙花產(chǎn)生時(shí)間 (|0轉(zhuǎn)化為整數(shù))
- this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
- }
- for(let i = this.fireworks.length - 1; i >= 0; --i){
- //渲染煙花 (若返回值為false則移除煙花)
- !this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
- }
- }
- }
- canvas.init();
完善
此時(shí)煙花是這樣的,感覺少了點(diǎn)小尾巴。
現(xiàn)在我們每一幀都是清除了畫布,如果要加上小尾巴其實(shí)也很簡單,每一幀都不要清除畫布,而是覆蓋一層新的有透明度的天空上去。
- //canvas.loop方法
- // this.fireworkCtx.clearRect(0, 0, this.width, this.height);
- this.fireworkCtx.fillStyle = config.skyColor;
- this.fireworkCtx.fillRect(0,0,this.width,this.height);
這時(shí)就變成這樣了。但是,還是缺少了在爆炸瞬間天空變亮的場景。那么在畫煙花的時(shí)候,先會獲取一下煙花的顏色以及透明度。
- // *****Firework constructor
- // this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
- this.hue = 360 * Math.random() | 0;
- this.color = `hsla(${this.hue},80%,60%,1)`;
- // *****Firework 新增實(shí)例方法
- getSkyColor(){
- const skyColor = {
- //只有炸裂階段才返回亮度
- lightness: this.status == 3 ? this.opacity : 0 ,
- hue: this.hue
- };
- return skyColor;
- }
- // *****config 修改config的skyColor
- // skyColor: 'hsla(210, 60%, 5%, 0.2)',
- skyColor: 'hsla({hue}, 60%, {lightness}%, 0.2)',
- // canvas.loop方法
- //this.fireworkCtx.fillStyle = config.skyColor;
- //每次替換色調(diào)與亮度值。
- this.fireworkCtx.fillStyle = config.skyColor.replace('{lightness}', 5 + this.skyColor.lightness * 15).replace('{hue}' , this.skyColor.hue);
- this.skyColor = { //新增
- lightness: 0,
- hue: 210
- };
- for(let i = this.fireworks.length - 1; i >= 0; --i){
- //新增 天空顏色為最亮的煙花的顏色
- this.skyColor = this.skyColor.lightness >= this.fireworks[i].getSkyColor().lightness ? this.skyColor : this.fireworks[i].getSkyColor();
- !this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
- }
到現(xiàn)在就算是大功告成了。
完整項(xiàng)目
Github 項(xiàng)目地址:https://github.com/NewNewKing/SmallRomance
留 言 有 禮 活 動
程序員的你會如何浪漫表白呢?掃描下方二維碼,關(guān)注51CTO技術(shù)棧公眾號。歡迎在技術(shù)棧微信公眾號留言探討。小編將精選出最有價(jià)值的三條評論,分別獲得 50、30、20 元 的 紅 包 獎(jiǎng) 勵(lì),活動截止時(shí)間 5 月 25 號 12 時(shí)整。